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