Logger
Introduction
A system used to easily log info to file and via on-screen messages
Log Levels
This plugin supports the following log types:
- Trace: Logs that contain the most detailed messages. These messages may contain sensitive application data. These messages are disabled by default and should never be enabled in a production environment
- Debug: Logs that are used for interactive investigation during development. These logs should primarily contain information useful for debugging and have no long-term value
- Information: Logs that track the general flow of the application. These logs should have long-term value
- Warning: Logs that highlight an abnormal or unexpected event in the application flow, but do not otherwise cause the application execution to stop
- Error: Logs that highlight when the current flow of execution is stopped due to a failure. These should indicate a failure in the current activity, not an application-wide failure
The log levels corresponds to the following verbosity level in Unreal Engine:
Log Level | Log Verbosity |
---|---|
Trace | VeryVerbose |
Debug | Verbose |
Information | Display |
Warning | Warning |
Error | Error |
API Reference
Functions
Name | Description | Params | Return |
---|---|---|---|
Configure | Configure the logger | Config (ULogConfig*) The new config file used by the logger |
|
Error | Log an error | Tag (FString) The category of the log entry Text (FString) The text to log out |
|
Warning | Log a warning | Tag (FString) The category of the log entry Text (FString) The text to log out |
|
Info | Log info | Tag (FString) The category of the log entry Text (FString) The text to log out |
|
Debug | Log debug information | Tag (FString) The category of the log entry Text (FString) The text to log out |
|
Trace | Log trace information | Tag (FString) The category of the log entry Text (FString) The text to log out |
Blueprint Usage
You can easily log info using Blueprints by adding one of the following nodes:
- Ultimate Starter Kit > Logger > Configure
- Ultimate Starter Kit > Logger > Log Trace
- Ultimate Starter Kit > Logger > Log Debug
- Ultimate Starter Kit > Logger > Log Info
- Ultimate Starter Kit > Logger > Log Warning
- Ultimate Starter Kit > Logger > Log Error
C++ Usage
The logging is handled through a static class/functions. You first need to enable the plugin in your Build.cs
file:
PublicDependencyModuleNames.Add("USK");
The logger can now be used in any of your C++ files:
#include "USK/Logger/Log.h"
void ATestActor::Test()
{
USK_LOG_TRACE("Testing trace logging");
USK_LOG_DEBUG("Testing debug logging");
USK_LOG_INFO("Testing info logging");
USK_LOG_WARNING("Testing warning logging");
USK_LOG_ERROR("Testing error logging");
ULog::Configure(Config);
ULog::Trace("Custom Tag", "Testing trace logging");
ULog::Debug("Custom Tag", "Testing debug logging");
ULog::Info("Custom Tag", "Testing info logging");
ULog::Warning("Custom Tag", "Testing warning logging");
ULog::Error("Custom Tag", "Testing error logging");
}