DDraceNetwork Docs
Log

Classes

class  CLogMessage
 
class  CFutureLogger
 
class  CLogScope
 

Functions

void log_log (LEVEL level, const char *sys, const char *fmt,...)
 
void log_log_color (LEVEL level, LOG_COLOR color, const char *sys, const char *fmt,...)
 
void log_log_v (LEVEL level, const char *sys, const char *fmt, va_list args)
 
void log_log_color_v (LEVEL level, LOG_COLOR color, const char *sys, const char *fmt, va_list args)
 
void log_set_global_logger (ILogger *logger)
 
void log_set_global_logger_default ()
 
void log_global_logger_finish ()
 
ILoggerlog_get_scope_logger ()
 
void log_set_scope_logger (ILogger *logger)
 
std::unique_ptr< ILoggerlog_logger_android ()
 
std::unique_ptr< ILoggerlog_logger_collection (std::vector< std::shared_ptr< ILogger > > &&vpLoggers)
 
std::unique_ptr< ILoggerlog_logger_file (IOHANDLE file)
 
std::unique_ptr< ILoggerlog_logger_stdout ()
 
std::unique_ptr< ILoggerlog_logger_windows_debugger ()
 
std::unique_ptr< ILoggerlog_logger_noop ()
 

Detailed Description

Methods for outputting log messages and way of handling them.

Function Documentation

◆ log_get_scope_logger()

ILogger * log_get_scope_logger ( )

Get the logger active in the current scope. This might be the global default logger or some other logger set via log_set_scope_logger.

◆ log_global_logger_finish()

void log_global_logger_finish ( )

Notify global loggers of impending abnormal exit.

This function is automatically called on normal exit. It notifies the global logger of the impending shutdown via GlobalFinish, the logger is supposed to flush its buffers and shut down.

Don't call this except right before an abnormal exit.

◆ log_log()

void log_log ( LEVEL  level,
const char *  sys,
const char *  fmt,
  ... 
)

Prints a log message.

Parameters
levelSeverity of the log message.
sysA string that describes what system the message belongs to.
fmtA printf styled format string.

◆ log_log_color()

void log_log_color ( LEVEL  level,
LOG_COLOR  color,
const char *  sys,
const char *  fmt,
  ... 
)

Prints a log message with a given color.

Parameters
levelSeverity of the log message.
colorRequested color for the log message output.
sysA string that describes what system the message belongs to.
fmtA printf styled format string.

◆ log_log_color_v()

void log_log_color_v ( LEVEL  level,
LOG_COLOR  color,
const char *  sys,
const char *  fmt,
va_list  args 
)

Same as log_log_color, but takes a va_list instead.

Parameters
levelSeverity of the log message.
colorRequested color for the log message output.
sysA string that describes what system the message belongs to.
fmtA printf styled format string.
argsThe variable argument list.

◆ log_log_v()

void log_log_v ( LEVEL  level,
const char *  sys,
const char *  fmt,
va_list  args 
)

Same as log_log, but takes a va_list instead.

Parameters
levelSeverity of the log message.
sysA string that describes what system the message belongs to.
fmtA printf styled format string.
argsThe variable argument list.

◆ log_logger_android()

std::unique_ptr< ILogger > log_logger_android ( )

Logger for sending logs to the Android system log.

Should only be called when targeting the Android platform.

◆ log_logger_collection()

std::unique_ptr< ILogger > log_logger_collection ( std::vector< std::shared_ptr< ILogger > > &&  vpLoggers)

Logger combining a vector of other loggers.

◆ log_logger_file()

std::unique_ptr< ILogger > log_logger_file ( IOHANDLE  file)

Logger for writing logs to the given file.

Parameters
fileFile to write to, must be opened for writing.

◆ log_logger_noop()

std::unique_ptr< ILogger > log_logger_noop ( )

Logger which discards all logs.

◆ log_logger_stdout()

std::unique_ptr< ILogger > log_logger_stdout ( )

Logger for writing logs to the standard output (stdout).

◆ log_logger_windows_debugger()

std::unique_ptr< ILogger > log_logger_windows_debugger ( )

Logger for sending logs to the debugger on Windows via OutputDebugStringW.

Should only be called when targeting the Windows platform.

◆ log_set_global_logger()

void log_set_global_logger ( ILogger logger)

Registers a logger instance as the default logger for all current and future threads. It will only be used if no thread-local logger is set via log_set_scope_logger.

This function can only be called once. The passed logger instance will never be freed.

Parameters
loggerThe global logger default.

◆ log_set_global_logger_default()

void log_set_global_logger_default ( )

Registers a sane default as the default logger for all current and future threads.

This is logging to stdout on most platforms and to the system log on Android.

See also
log_set_global_logger

◆ log_set_scope_logger()

void log_set_scope_logger ( ILogger logger)

Set the logger for the current thread. The logger isn't managed by the logging system, it still needs to be kept alive or freed by the caller.

Consider using CLogScope if you only want to set the logger temporarily.

See also
CLogScope