Home
Base module

Logger

Logger class.

Logger

#include <icy/logger.h>
class Logger

Defined in src/base/include/icy/logger.h:156

Logger class.

List of all members

NameKindOwner
Singleton< Logger >friendDeclared here
ThreadfriendDeclared here
LoggerfunctionDeclared here
~LoggerfunctionDeclared here
addfunctionDeclared here
removefunctionDeclared here
getfunctionDeclared here
setDefaultfunctionDeclared here
setWriterfunctionDeclared here
getDefaultfunctionDeclared here
writefunctionDeclared here
writefunctionDeclared here
instancefunctionDeclared here
setInstancefunctionDeclared here
destroyfunctionDeclared here
levelEnabledfunctionDeclared here
lowerLevelFilterfunctionDeclared here
_mutexvariableDeclared here
_channelsvariableDeclared here
_defaultChannelvariableDeclared here
_writervariableDeclared here
LoggerfunctionDeclared here
operator=functionDeclared here
LoggerfunctionDeclared here
operator=functionDeclared here

Friends


Singleton< Logger >

friend class Singleton< Logger >

Defined in src/base/include/icy/logger.h:228


Thread

friend class Thread

Defined in src/base/include/icy/logger.h:233

Public Methods

ReturnNameDescription
Logger
voidaddAdds the given log channel. Takes ownership.
voidremoveRemoves the given log channel by name.
LogChannel *get constReturns the specified log channel. Throws an exception if the channel doesn't exist.
voidsetDefaultSets the default log to the specified log channel.
voidsetWriterSets the log writer instance. Takes ownership.
LogChannel *getDefault constReturns the default log channel, or the nullptr channel if no default channel has been set.
voidwriteWrites the given message to the default log channel. The message will be copied.
voidwriteWrites the given message to the default log channel.

Logger

Logger()

Defined in src/base/include/icy/logger.h:159


add

void add(std::unique_ptr< LogChannel > channel)

Defined in src/base/include/icy/logger.h:173

Adds the given log channel. Takes ownership.


remove

void remove(std::string_view name)

Defined in src/base/include/icy/logger.h:176

Removes the given log channel by name.


get

const

LogChannel * get(std::string_view name, bool whiny = true) const

Defined in src/base/include/icy/logger.h:180

Returns the specified log channel. Throws an exception if the channel doesn't exist.


setDefault

void setDefault(std::string_view name)

Defined in src/base/include/icy/logger.h:183

Sets the default log to the specified log channel.


setWriter

void setWriter(std::unique_ptr< LogWriter > writer)

Defined in src/base/include/icy/logger.h:186

Sets the log writer instance. Takes ownership.


getDefault

const

LogChannel * getDefault() const

Defined in src/base/include/icy/logger.h:190

Returns the default log channel, or the nullptr channel if no default channel has been set.


write

void write(const LogStream & stream)

Defined in src/base/include/icy/logger.h:194

Writes the given message to the default log channel. The message will be copied.


write

void write(std::unique_ptr< LogStream > stream)

Defined in src/base/include/icy/logger.h:197

Writes the given message to the default log channel.

Public Static Methods

ReturnNameDescription
Logger &instance staticReturns the default logger singleton. Logger instances may be created separately as needed.
voidsetInstance staticSets the default logger singleton instance.
voiddestroy staticDestroys the default logger singleton instance.
boollevelEnabled static inline noexceptReturns true if a message at the given level could be accepted by any existing channel. Cheap (single relaxed atomic load) so the logging macros can skip argument formatting entirely when the level is filtered out. Conservative: never filters a deliverable message, but raising a channel's level does not raise the filter back.
voidlowerLevelFilter static inline noexceptLowers the global level filter so messages at level and above pass [levelEnabled()](#levelenabled). Called by [LogChannel](icy-LogChannel.html#logchannel) on construction and setLevel().

instance

static

static Logger & instance()

Defined in src/base/include/icy/logger.h:164

Returns the default logger singleton. Logger instances may be created separately as needed.


setInstance

static

static void setInstance(Logger * logger, bool freeExisting = true)

Defined in src/base/include/icy/logger.h:167

Sets the default logger singleton instance.


destroy

static

static void destroy()

Defined in src/base/include/icy/logger.h:170

Destroys the default logger singleton instance.


levelEnabled

static inline noexcept

static inline bool levelEnabled(Level level) noexcept

Defined in src/base/include/icy/logger.h:204

Returns true if a message at the given level could be accepted by any existing channel. Cheap (single relaxed atomic load) so the logging macros can skip argument formatting entirely when the level is filtered out. Conservative: never filters a deliverable message, but raising a channel's level does not raise the filter back.


lowerLevelFilter

static inline noexcept

static inline void lowerLevelFilter(Level level) noexcept

Defined in src/base/include/icy/logger.h:213

Lowers the global level filter so messages at level and above pass [levelEnabled()](#levelenabled). Called by [LogChannel](icy-LogChannel.html#logchannel) on construction and setLevel().

Protected Attributes

ReturnNameDescription
std::mutex_mutex
LogChannelMap_channels
LogChannel *_defaultChannel
std::unique_ptr< LogWriter >_writer

_mutex

std::mutex _mutex

Defined in src/base/include/icy/logger.h:235


_channels

LogChannelMap _channels

Defined in src/base/include/icy/logger.h:236


_defaultChannel

LogChannel * _defaultChannel

Defined in src/base/include/icy/logger.h:237


_writer

std::unique_ptr< LogWriter > _writer

Defined in src/base/include/icy/logger.h:238

Protected Methods

ReturnNameDescription
LoggerNonCopyable and NonMovable.
LoggerDeleted constructor.

Logger

Logger(const Logger &) = delete

Defined in src/base/include/icy/logger.h:225

NonCopyable and NonMovable.


Logger

Logger(Logger &&) = delete

Defined in src/base/include/icy/logger.h:227

Deleted constructor.