Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Logging System

Dylan Dumesnil edited this page Jun 30, 2020 · 1 revision

MDLog proivdes various levels of logging and allows you to have separate log levels of logging for console and file. Each category can be set independently.

The available log levels are:

    Trace,
    Debug,
    Info,
    Warn,
    Error,
    Fatal,
    Force

To log with a specific level, use the log level as the function. For example, to log an error use MDLog.Error(). The first parameter is the log category string, the second is the format string, and then any arguments to want to pass to your format string:

MDLog.Info(LOG_CAT, "Peer [ID: {0}] connected", PeerId);

Will give something like

[2020-04-12 16:48:03.404][58][SERVER] [LogGameSession::Info] Peer [ID: 168151027] connected

Conditional variants are also available, where the first parameter is a condition that must be true for the log to happen:

bool Success = error == Error.Ok;
MDLog.CInfo(Success, LOG_CAT, "Connecting to server at {0}:{1}", Address, Port);

Logging with a log level of Fatal will trigger a break if the debugger is attached.

To configure the log level for a specific category call:

MDLog.AddLogCategoryProperties(LOG_CAT, new MDLogProperties(MDLogLevel FileLogLevel, MDLogLevel ConsoleFileLogLevel));

You can change the log level of a category at runtime using the command SetLogLevel [Category] [LogLevel]. For example SetLogLevel LogMDGameSession Debug.

Clone this wiki locally