How-To: Set Up Per-Plugin Logging
Goal: give a plugin its own named, filterable log category using the CRIMSON_LOG_* macros. Every Crimson plugin uses these exclusively - never UE_LOG directly, and never DEFINE_LOG_CATEGORY_STATIC (static categories can't be filtered by name in the output log).
Prerequisites
This is a C++ task. The plugin's
.Build.cs lists CrimsonCommon in PublicDependencyModuleNames, and its .uplugin declares CrimsonCommon in the Plugins array.1. Declare the category (one header)
// Public/CrimsonMyPluginLog.h#pragma once#include "CrimsonLogging.h"CRIMSON_DECLARE_LOG_CATEGORY(LogCrimsonMyPlugin)
2. Define it (module .cpp, once)
// CrimsonMyPluginModule.cpp#include "CrimsonMyPluginLog.h"CRIMSON_DEFINE_LOG_CATEGORY(LogCrimsonMyPlugin);
3. Log at call sites
#include "CrimsonMyPluginLog.h"CRIMSON_LOG_INFO (LogCrimsonMyPlugin, TEXT("Bindings applied"))CRIMSON_LOG_WARN (LogCrimsonMyPlugin, TEXT("Config is null"))CRIMSON_LOG_ERROR(LogCrimsonMyPlugin, FString::Printf(TEXT("Tag [%s] not found"), *Tag.ToString()))
| Macro | Verbosity | When to use |
|---|---|---|
CRIMSON_LOG_VERBOSE | Verbose | Per-frame / high-frequency detail |
CRIMSON_LOG_INFO | Log | Normal operational info |
CRIMSON_LOG_DISPLAY | Display | Shows in the PIE on-screen log |
CRIMSON_LOG_WARN | Warning | Unexpected but recoverable |
CRIMSON_LOG_ERROR | Error | Operation failed |
CRIMSON_LOG_FATAL | Fatal | Unrecoverable - flushes and crashes |
Verify
Run the editor and type
Log LogCrimsonMyPlugin Verbose in the console - your category is listed and filterable by name.