Skip to main content

Logging

The FACEIT SDK outputs log messages during operation. Each SDK feature outputs its log messages on a corresponding log channel, whose verbosity may be set according to user preference.

Although the examples below are written in reference to the game client SDK, the same principle applies for the server SDK.

Log Callback

If a developer chooses to use the FACEIT SDK libraries directly, they must set a log callback in order to receive log messages. The developer may then choose to forward these log messages however they like - for example, to an output stream, or a file on disk.

info

Log messages emitted by the FACEIT Unreal Engine plugins do not require a callback to be set. These messages are passed directly to Unreal's logging system, using Unreal logging classes defined for the client and server plugins respectively.

#include <string>
#include <cstdio>
#include "FACEITGameClientSDK/Log.h"
#include "FACEITGameClientSDK/Utilities/StringHelpers.h"

FGCSDK_SetLogMessageCallback(
[](const FGCSDK_LogMessageCallbackInfo* info)
{
const std::string logChannelString = FGCSDK_ToString(FGCSDK_GetLogChannelString, info->channel);
const std::string logLevelString = FGCSDK_ToString(FGCSDK_GetLogLevelString, info->level);

// This call prints a log message that might look like:
// [Matchmaking] (Session:BeginSession) Warning: This is a warning message
printf("[%s] (%s:%s) %s: %s\n",
logChannelString.c_str(),
info->context,
info->source,
logLevelString.c_str(),
info->message);
});

The log callback can also be cleared by calling ClearLogMessageCallback().

FGCSDK_ClearLogMessageCallback();

Log Levels

Log verbosity levels can be set per channel, or a single level may be set collectively for all channels. When setting a verbosity level, only log messages that are at least as severe as this level will be emitted on the log callback.

Setting a log level for a specific channel can either be done by calling the SetLogVerbosity() function in the logging interface and specifying a channel:

#include "FACEITGameClientSDK/Log.h"

FGCSDK_SetLogVerbosity(FGCSDK_ANTICHEAT_LOG_CHANNEL, FGCSDK_LOG_DEBUG);

Or by calling the SetLogVerbosity() function included in the interface for a specific feature:

#include "FACEITGameClientSDK/Anticheat/Anticheat.h"

FGCSDK_AC_SetLogVerbosity(FGCSDK_LOG_DEBUG);

Setting the same log verbosity level for all SDK log channels can be achieved by calling the SetLogVerbosityForEveryChannel() function in the logging interface.

#include "FACEITGameClientSDK/Log.h"

FGCSDK_SetLogVerbosityForEveryChannel(FGCSDK_LOG_DEBUG);
info

The Match Life Cycle feature in the server SDK will automatically update the log level from the value stored in the FACEIT_SERVER_PLUGIN_LOGLEVEL environment variable. This update is performed when a new Match Life Cycle session is started.

The Match Life Cycle feature is currently the only area of the server SDK where changing settings via environment variables is supported. Other interfaces may support this in future.