Class Logger

Nested Relationships

Nested Types

Class Documentation

class Logger

Logging manager singleton.

Public Types

enum class Level

Level of severity for log messages.

Values:

enumerator Trace

Debug information, usually unneeded.

enumerator Info

Information.

enumerator Warn

Warnings.

enumerator Error

Errors.

enumerator Fatal

Fatal Errors.

Public Static Functions

static Logger &Get()

Get the instance and create one if there isn’t one.

Returns:

The instance

static LogToken Engine(Level level = Level::Info)

Log a message from the engine.

Note

For use only by the engine internally.

Parameters:

level – The severity of the message (optional, defaults to Info)

Returns:

A LogToken, which is streamed into like std::cout and logs the resulting message upon destruction. Do not store this return value.

static LogToken Client(Level level = Level::Info)

Log a message from the client.

Note

For use by engine clients.

Parameters:

level – The severity of the message (optional, defaults to Info)

Returns:

A LogToken, which is streamed into like std::cout and logs the resulting message upon destruction. Do not store this return value.

struct LogToken

A small object used to make the logging API more ergonomic.

Use operator<< with it just like with std::cout to write log messages (no ending newline or std::endl necessary) You can also use LogFormatted just like you would std::format

Public Functions

LogToken() = default
LogToken(const LogToken&) = delete
LogToken(LogToken&&) = default
LogToken &operator=(const LogToken&) = delete
LogToken &operator=(LogToken&&) = default
template<typename T>
inline LogToken &operator<<(const T &value)

Add a value to the log stream.

Parameters:

value – The value to log (ostream overrides for formatting like std::ostream& operator<<(std::ostream& out, const T& val)) should work

Returns:

This object to continue the stream chain

template<typename ...Args>
inline void LogFormatted(std::format_string<Args...> fmtstr, Args&&... args)

Add a formatted string to the log stream.

Parameters:
  • fmtstr – The format string to log

  • args – The arguments to the format string

template<typename ...Args>
inline void LogFormatted(const std::locale &locale, std::format_string<Args...> fmtstr, Args&&... args)

Add a formatted string to the log stream with an explicit locale.

Parameters:
  • locale – The locale to use for formatting

  • fmtstr – The format string to log

  • args – The arguments to the format string

inline ~LogToken()

Public Members

Level lvl
std::ostringstream oss
bool isClient