Logging System of Diarkis Module

Overview and setup of the logging system for the Diarkis Module

Overview

This page explains the logging system of the Diarkis Module.

The Diarkis Module outputs logs from the Diarkis runtime library as well as the module's operational status. These logs can be checked through various methods such as standard output or file output. If the system does not function as expected or if you need to check the operational status of the Diarkis runtime, it is recommended to first review the contents of the log files.

Setting up the Logging System

The logging system settings for the Diarkis Module are controlled by the arguments passed to DiarkisInterfaceBase::DiarkisInit(). You can set the log directory name, output method, whether to output logs, etc.

Log Output Methods of Diarkis Module

The Diarkis Module supports the following output methods:

enumDescription

DEBUG_OUT

Outputs logs to the debugger if possible, otherwise to standard output.

FILE_OUT

Outputs logs to a file named diarkis-log.log in the path retrieved by GetLogDirectoryPath().

FILE_OUT_SPECIFIC_PATH

Outputs logs to a specified path.

CONSOLE_OUT

Outputs logs to standard output.

DEBUG_AND_FILE_OUT

Combines the behavior of DEBUG_OUT and FILE_OUT.

CUSTOM

Outputs logs to a user-defined custom logger.

Log Output Levels

The logging system of the Diarkis Module allows you to set log output levels to adjust the detail of the output. The default log output level is recorded in the constructor of LoggerFactory, implemented in diarkis-module\Client\Private\logging\LoggerFactory.cpp, and can be changed. Additionally, you can dynamically change it during application execution using LoggerFactory::SetSeverity().

The log output levels are as follows. The lower the setting, the more detailed the logs. Higher log levels always include lower log levels. Note that using Verbose or Trace may affect the runtime speed of Diarkis or result in large log files, so use them with caution.

enumDescription

None

Does not output logs.

Fatal

Outputs logs for fatal errors.

Error

Outputs logs including general errors.

Warning

Outputs logs including warnings.

Info

Outputs logs including additional information.

Debug

Outputs logs including debugging information.

Verbose

Outputs logs including detailed debugging information.

Trace

Outputs logs with the highest level of detail, including runtime operations and payload details.

Log Contents by Category

The logging system of the client library provides a mechanism to change log levels by category. Adjust the log level for the necessary categories according to what you need to debug.

Typical CategoriesDebugging Content

UDP

Check connections and disconnections with the UDP server. Verify ack and eack when packet loss occurs.

RUDP

Check the processing status of RUDP packets and sequence numbers when packet loss occurs.

Socket

Verify socket operations when unexpected disconnections occur.

P2P

Check for issues around hole punching and packet communication during P2P communication.

Runtime

Check packet transmissions and notifications or responses from the server when implementing an application.

Categories like Room for each module

Check packet transmissions and notifications or responses from the server when implementing each module.

Implementing a Custom Logger

By using a custom logger, you can freely customize the logging behavior. By inheriting ILoggerBackend and overriding ILoggerBackend::Log(), you can handle the log output processing of the Diarkis runtime and the Diarkis Module. Below is a sample implementation.

// Sample implementation of application-specific log output
class AppCustomLoggerBackend : public ILoggerBackend
{
    public:
        AppCustomLoggerBackend() {}
        virtual ~AppCustomLoggerBackend() {}

        virtual Result Log(const Diarkis::StdString& message, bool includeNewLine) override
        {
            // Logs are passed as message, allowing application-specific log output
            // Mutex is handled, so it is safe to call from multiple threads
            DiarkisUtils::Print("%s", message.c_str());
            return Diarkis::Results::SUCCESS;
        }
};

...
// Example code for specifying a custom logger during initialization
AppCustomLoggerBackend customLogger;

DiarkisInterface::DiarkisInit(uid, LogOutType::CUSTOM, bOutLog, &customLogger);

Last updated