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:

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.

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.

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);

最終更新