Base module

Logger

[Logger]({#ref classicy_1_1Logger #}) class.

Logger

#include <icy/logger.h>

Logger class.

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()

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) const

Returns 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() const

Returns 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

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.

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

ReturnNameDescription
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 > _writer

Protected Methods

ReturnNameDescription
LoggerNonCopyable and NonMovable.
LoggerDeleted constructor.

Logger

Logger(const Logger &) = delete

NonCopyable and NonMovable.


Logger

Logger(Logger &&) = delete

Deleted constructor.