Home
Base module

Logger

Logger class.

Logger

#include <icy/logger.h>
class Logger

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

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
_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:203


Thread

friend class Thread

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

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:158


add

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

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

Adds the given log channel. Takes ownership.


remove

void remove(std::string_view name)

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

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:179

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:182

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:185

Sets the log writer instance. Takes ownership.


getDefault

const

LogChannel * getDefault() const

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

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:193

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:196

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

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

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:166

Sets the default logger singleton instance.


destroy

static

static void destroy()

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

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

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


_channels

LogChannelMap _channels

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


_defaultChannel

LogChannel * _defaultChannel

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


_writer

std::unique_ptr< LogWriter > _writer

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

Protected Methods

ReturnNameDescription
LoggerNonCopyable and NonMovable.
LoggerDeleted constructor.

Logger

Logger(const Logger &) = delete

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

NonCopyable and NonMovable.


Logger

Logger(Logger &&) = delete

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

Deleted constructor.