Logging System of Diarkis Module

Overview

This page explains the logging system of the Diarkis Module.

In the Diarkis Module, logs are output for the Diarkis runtime library and the operation status of the Diarkis Module. The output logs can be viewed using various methods such as standard output or file output. If you are experiencing unexpected behavior or want to check the status of Diarkis runtime, we recommend reviewing the log files as the first step.

Logging System Configuration

The logging system configuration for the Diarkis Module is controlled by the arguments passed to DiarkisInterfaceBase::DiarkisInit(). You can configure options such as log directory name, output method, and whether to produce logs.

Diarkis Module Log Output Methods

The Diarkis Module supports the following output methods:

Enum
Description

DEBUG_OUT

Logs are output to the debugger if possible; otherwise, they are sent to standard output.

FILE_OUT

Logs are output to a file. The file is named diarkis-log.log in the path obtained by GetLogDirectoryPath().

FILE_OUT_SPECIFIC_PATH

Logs are output to a specified path.

CONSOLE_OUT

Logs are output to standard output.

DEBUG_AND_FILE_OUT

Combines the behaviors of DEBUG_OUT and FILE_OUT.

CUSTOM

Logs are output to a user-defined custom logger.

Log Output Levels

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

The log output levels are as follows. The settings further down the list provide more detailed logs. Furthermore, higher detail log levels always encompass lower log levels. Please be careful when using Verbose or Trace, as they may affect the runtime speed of Diarkis or cause log files to become large.

Enum
Description

None

Do not output logs.

Fatal

Output logs for critical errors.

Error

Output logs including general errors.

Warning

Output logs including warnings.

Info

Output logs with additional information.

Debug

Output logs including debugging information.

Verbose

Output logs with detailed debugging information.

Trace

Output detailed logs of runtime operations and transmitted/received payloads.

Log Contents by Category

The logging system of the client library provides a mechanism to change log levels by category. Adjust the log levels of the necessary categories according to the content you wish to check during debugging.

Representative Category
Content Verifiable During Debugging

UDP

Verification of Connect, Disconnect with the UDP server. Unexpected disconnections and ack, eack during packet loss.

RUDP

Verification of RUDP packets and sequence number processing during packet loss.

Socket

Verification of socket operations when unexpected disconnections occur.

P2P

Issues around hole punching and packet communication during P2P communications.

Runtime

Verification when implementing applications and there are no notifications or responses from the server during packet sending/receiving.

Categories for Each Module like Room

Verification during implementation of each module when there are no notifications or responses from the server during packet sending/receiving.

Implementing a Custom Logger

Using a custom logger allows the user to freely customize the logger's operations. By inheriting from ILoggerBackend and overriding ILoggerBackend::Log(), you can handle the log output processing of the Diarkis runtime and Diarkis Module. Below is a sample implementation.

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

        virtual Result Log(const Diarkis::StdString& message, bool includeNewLine) override
        {
            // Log text is passed as a message, perform application-specific log output
            // Thread-safe due to exclusive control, safe for calls from multiple threads
            DiarkisUtils::Print("%s", message.c_str());
            return Diarkis::Results::SUCCESS;
        }
};

...
// Pseudocode to specify a custom logger during initialization
AppCustomLoggerBackend customLogger;

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

Last updated