Logger
Logger
#include <icy/logger.h>Logger class.
Public Methods
| Return | Name | Description |
|---|---|---|
Logger | ||
void | add | Adds the given log channel. Takes ownership. |
void | remove | Removes the given log channel by name. |
LogChannel * | get const | Returns the specified log channel. Throws an exception if the channel doesn't exist. |
void | setDefault | Sets the default log to the specified log channel. |
void | setWriter | Sets the log writer instance. Takes ownership. |
LogChannel * | getDefault const | Returns the default log channel, or the nullptr channel if no default channel has been set. |
void | write | Writes the given message to the default log channel. The message will be copied. |
void | write | Writes the given message to the default log channel. |
Logger
Logger()add
void add(std::unique_ptr< LogChannel > channel)Adds the given log channel. Takes ownership.
remove
void remove(std::string_view name)Removes the given log channel by name.
get
const
LogChannel * get(std::string_view name, bool whiny) constReturns the specified log channel. Throws an exception if the channel doesn't exist.
setDefault
void setDefault(std::string_view name)Sets the default log to the specified log channel.
setWriter
void setWriter(std::unique_ptr< LogWriter > writer)Sets the log writer instance. Takes ownership.
getDefault
const
LogChannel * getDefault() constReturns the default log channel, or the nullptr channel if no default channel has been set.
write
void write(const LogStream & stream)Writes the given message to the default log channel. The message will be copied.
write
void write(std::unique_ptr< LogStream > stream)Writes the given message to the default log channel.
Public Static Methods
| Return | Name | Description |
|---|---|---|
Logger & | instance static | Returns the default logger singleton. Logger instances may be created separately as needed. |
void | setInstance static | Sets the default logger singleton instance. |
void | destroy static | Destroys the default logger singleton instance. |
instance
static
static Logger & instance()Returns the default logger singleton. Logger instances may be created separately as needed.
setInstance
static
static void setInstance(Logger * logger, bool freeExisting)Sets the default logger singleton instance.
destroy
static
static void destroy()Destroys the default logger singleton instance.
Protected Attributes
| Return | Name | Description |
|---|---|---|
std::mutex | _mutex | |
LogChannelMap | _channels | |
LogChannel * | _defaultChannel | |
std::unique_ptr< LogWriter > | _writer |
_mutex
std::mutex _mutex_channels
LogChannelMap _channels_defaultChannel
LogChannel * _defaultChannel_writer
std::unique_ptr< LogWriter > _writerProtected Methods
Logger
Logger(const Logger &) = deleteNonCopyable and NonMovable.
Logger
Logger(Logger &&) = deleteDeleted constructor.
