LoggerInterface Class Reference

#include <logger.h>

Public Types

using LOGGERTYPEINITCALLBACK = Delegate< Result< void >(LoggerTypeRef &logger)>
 

Public Member Functions

MAXON_METHOD Result< void > AddLoggerType (TARGETAUDIENCE ta, const Class< LoggerTypeRef > &loggerTypeCls, const LOGGERTYPEINITCALLBACK &cb=DefaultLoggerTypeInit)
 
MAXON_METHOD Result< void > RemoveLoggerType (LoggerTypeRef &loggerType)
 
MAXON_METHOD Result< void > RemoveLoggerTypes (const Class< LoggerTypeRef > &loggerTypeCls)
 
MAXON_METHOD Result< void > Write (TARGETAUDIENCE ta, const String &str, const maxon::SourceLocation &loc, WRITEMETA level=WRITEMETA::DEFAULT)
 
MAXON_METHOD String GetName () const
 
MAXON_METHOD void SetName (const String &name)
 
MAXON_METHOD void Enable (Bool enable)
 
MAXON_METHOD Bool IsEnabled ()
 
MAXON_METHOD BaseArray< Pair< LoggerTypeRef, TARGETAUDIENCE > > GetLoggerTypes () const
 
 MAXON_OBSERVABLE_STATIC (void, ObservableLoggerNew,(const LoggerRef &logger), ObservableCombinerRunAllComponent)
 

Static Public Member Functions

static MAXON_METHOD LoggerInterfaceAlloc (MAXON_SOURCE_LOCATION_DECLARATION)
 
static MAXON_METHOD Result< void > AddNewLogger (const Id &id, const LoggerRef &logger, const maxon::ModuleInfo *module=&PRIVATE_MAXON_MODULE)
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL (LoggerInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.logger")
 

Static Private Member Functions

static Result< void > DefaultLoggerTypeInit (LoggerTypeRef &)
 

Member Typedef Documentation

◆ LOGGERTYPEINITCALLBACK

using LOGGERTYPEINITCALLBACK = Delegate<Result<void>(LoggerTypeRef& logger)>

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( LoggerInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.interface.logger"   
)
private

◆ Alloc()

Allocates a logger.

◆ AddLoggerType()

MAXON_METHOD Result<void> AddLoggerType ( TARGETAUDIENCE  ta,
const Class< LoggerTypeRef > &  loggerTypeCls,
const LOGGERTYPEINITCALLBACK cb = DefaultLoggerTypeInit 
)

Adds a logger type to the logger.

Parameters
[in]taSet the audience. The logger type will get the string if the target audience matches when LoggerInterface::Write is used.
[in]loggerTypeClsClass object of logger type ref (e.g. maxon::LoggerTypes::Application())
[in]cbOptional callback that is executed to initialize a logger type after added to the logger. E.g. the file logger needs to be initialized with a destination path.

◆ RemoveLoggerType()

MAXON_METHOD Result<void> RemoveLoggerType ( LoggerTypeRef &  loggerType)

Removes a logger type from a logger. Also succeeds if the logger type was not part of the logger.

◆ RemoveLoggerTypes()

MAXON_METHOD Result<void> RemoveLoggerTypes ( const Class< LoggerTypeRef > &  loggerTypeCls)

Removes all logger types of the passed type.

Parameters
[in]loggerTypeClsAll logger types with the passed class type will be removed.

◆ Write()

MAXON_METHOD Result<void> Write ( TARGETAUDIENCE  ta,
const String str,
const maxon::SourceLocation loc,
WRITEMETA  level = WRITEMETA::DEFAULT 
)

Sends a string to all added logger types.

Parameters
[in]taAll logger types which match the target audience will receive the string.
[in]strString to print.
[in]locSource location where the string was printed from.
[in]levelMeta information for the current write operation.

◆ GetName()

MAXON_METHOD String GetName ( ) const

Returns the name of the logger.

Returns
The name.

◆ SetName()

MAXON_METHOD void SetName ( const String name)

Sets the name of the logger.

Parameters
[in]nameThe name.

◆ Enable()

MAXON_METHOD void Enable ( Bool  enable)

Enable or disable the logger. If disabled, the logger still consumes strings but discards them.

Parameters
[in]enableTrue or false to enable or disable the logger.

◆ IsEnabled()

MAXON_METHOD Bool IsEnabled ( )

Returns if the logger is enabled.

Returns
True or false.

◆ GetLoggerTypes()

MAXON_METHOD BaseArray<Pair<LoggerTypeRef, TARGETAUDIENCE> > GetLoggerTypes ( ) const

Returns all logger types including their audience.

Returns
An array of pairs with logger types and the audience.

◆ MAXON_OBSERVABLE_STATIC()

MAXON_OBSERVABLE_STATIC ( void  ,
ObservableLoggerNew  ,
(const LoggerRef &logger)  ,
ObservableCombinerRunAllComponent   
)

Add observer to get notified once a new logger got added.

Parameters
[in]loggerThe new logger

◆ AddNewLogger()

static MAXON_METHOD Result<void> AddNewLogger ( const Id id,
const LoggerRef &  logger,
const maxon::ModuleInfo *  module = &PRIVATE_MAXON_MODULE 
)
static

Add a new logger to the system. Does the same as Loggers::Insert, but also triggers the observers

Parameters
[in]moduleThe module which initiates the call. When the module is freed, the logger will be freed too.
Returns
An array of pairs with logger types and the audience.

◆ DefaultLoggerTypeInit()

static Result<void> DefaultLoggerTypeInit ( LoggerTypeRef &  )
staticprivate