class Log

Used for logging messages.

Messages can be categorized and filtered by verbosity, the log can be saved to a file and send out callbacks when a new message is added.

Public

Constructors

Log

Log() = default

Methods

~Log

~Log()

LogMessage

void LogMessage(const String &message, LogVerbosity verbosity, const String &categoryName)

Logs a new message.

message
The message describing the log entry.
verbosity
Verbosity of the message, determining its importance.
categoryName
Category of the message, determining which system is it relevant to.

Clear

void Clear()

Removes all log entries.

Clear

void Clear(const String &categoryName, LogVerbosity verbosity = LogVerbosity::Any)

Removes all log entries for a specific category and/or verbosity level.

categoryName
Name of the category to clear. Specify empty string to clear all categories.
verbosity
Verbosity level to clear.

GetEntries

Vector<LogEntry> GetEntries() const

Returns all existing log entries.

GetUnreadEntry

bool GetUnreadEntry(LogEntry &outEntry)

Returns the latest unread entry from the log queue, and removes the entry from the unread entries list.

outEntry
Entry that was retrieved, or undefined if no entries exist.

Returns: True if an unread entry was retrieved, false otherwise.

GetLastEntry

bool GetLastEntry(LogEntry &outEntry)

Returns the last available log entry.

outEntry
Entry that was retrieved, or undefined if no entries exist.

Returns: True if an entry was retrieved, false otherwise.

GetHash

u64 GetHash() const

Returns a hash value that is modified whenever entries in the log change.

This can be used for checking for changes by external systems.

staticSetCategoryMaximumVerbosity

static void SetCategoryMaximumVerbosity(const char *name, LogVerbosity maximumVerbosity)

Changes the maximum verbosity for a particular log category.

Verbosity levels higher than specified verbosity will not be logged.

Internal

Methods

staticRegisterCategory

static void RegisterCategory(LogCategoryBase &category)

Registers the new category object.

staticUnregisterCategory

static void UnregisterCategory(LogCategoryBase &category)

Unregisters an existing category object.

Private

Methods

staticGetCategoriesMap

static UnorderedMultimap<const char *, LogCategoryBase *> &GetCategoriesMap()

Returns a modifyable map containing all the log categories.

GetAllEntries

Vector<LogEntry> GetAllEntries() const

Returns all log entries, including those marked as unread.

Fields

mEntries

Vector<LogEntry> mEntries

mUnreadEntries

Queue<LogEntry> mUnreadEntries

mHash

u64 mHash

mMutex

RecursiveMutex mMutex