Repository navigation
Logging
VOID provides asynchronous process-wide logging through Logger.Instance.
Messages can use levels, categories, composite formatting, exceptions, and custom sinks.
var logger =
Logger.Instance;
logger.Debug(
"Loading level");
logger.Info(
"Game started");
logger.Warning(
"Low memory warning");
try
{
LoadSomething();
}
catch (Exception ex)
{
logger.Error(
ex,
"Failed to load content");
}Formatted messages use the normal composite-format style:
logger.Info(
"Player position: {0}, {1}",
x,
y);| Level | Use |
|---|---|
Debug |
Development/troubleshooting detail |
Info |
Normal application operation |
Warning |
Potential problem that can continue |
Error |
Failure that may still allow continued operation |
Fatal |
Severe failure; writes and flushes immediately |
None |
Suppresses normal log output when used as the minimum level |
Set the minimum:
logger.SetLevel(
LogLevel.Info);Messages below the configured level are discarded before formatted arguments are expanded.
Use the WithCategory methods to group output by subsystem:
logger.InfoWithCategory(
"Network",
"Connected to server");
logger.WarningWithCategory(
"Audio",
"Voice pool is nearly full");
logger.ErrorWithCategory(
"Assets",
exception,
"Failed to load player texture");Fatal writes the entry and flushes queued logs:
Logger.Instance.Fatal(
"Renderer initialization failed");Critical is intentionally stronger.
It writes crash-style details, includes a stack trace, flushes pending logs, and then throws an InvalidOperationException:
Logger.Instance.CriticalWithCategory(
"Renderer",
"Framebuffer creation failed");Use Critical only when continuing execution is not valid.
When Game starts, VOID adds:
ConsoleSinkFileSink
The logger level and file retention settings come from GameSettings.
Configure them before Build():
var settings =
GameSettings.Instance
.SetLogMinLevel(
LogLevel.Info)
.SetLogMaxFileSizeMB(10)
.SetLogMaxFiles(10)
.Build();Log files are written under Game.Instance.ApplicationLogFolder.
See Game Class → Application Folders.
FileSink creates daily files:
log_13-09-2026.txt
When a file reaches the configured size limit, the sink rolls to numbered files:
log_13-09-2026_1.txt
log_13-09-2026_2.txt
Retention cleanup removes older matching log files once the configured maximum count is exceeded.
The logger:
- queues entries for a background writer thread
- processes entries in batches
- bounds the queue to prevent unlimited memory growth
- serializes sink writes
- isolates sink failures so one sink does not stop the others
- can be called from multiple threads
The current queue limit is 10,000 entries and the worker processes batches of up to 100 entries.
Force queued entries to be written:
Logger.Instance.Flush();Fatal and Critical paths flush automatically.
Implement ILogSink:
public sealed class DatabaseSink
: ILogSink
{
public void Write(
LogEntry entry)
{
// Store or forward the entry.
}
}Register it:
Logger.Instance.AddSink(
new DatabaseSink());Remove it later if needed:
Logger.Instance.RemoveSink(
sink);See Extensibility → Custom Log Sink.
Home · Getting Started · Rendering · Custom Renderers · GitHub · Report an Issue
Built with VOID Engine · MIT License
- Coroutines
- State Machine
- Save System
- Pathfinding
- Logging
- Beacon Manager
- Beacon Event System
- Discoverable System
- Instance Helper
- BeaconManager Extensions
- BeaconHandle Extensions
- Enum Extensions
- String Extensions
- Int Extensions
- Float Extensions
- IEnumerable Extensions
- Random Extensions
- Sound Extensions
- Font Extensions