Logging Framework
Namespace: RisingV.Shared.Logging
Assembly: RisingV.Shared
The RisingV Logging abstraction provides a lightweight facade over BepInEx’s log API, wrapping it with:
- Structured messages (
ILogger.Log(level, message, params)
) - Static factory that binds loggers to calling types (
Logger.Create<T>()
) - Tag system for feature‑level filtering
1. Quick‑Start
using RisingV.Shared.Logging;
public class CombatEngine
{
private static readonly Logger Log = Logger.Create<CombatEngine>();
public void DealDamage(Entity target, int amount)
{
Log.Debug("Dealing {} to {}", amount, target);
// …
}
}
Output (with default template):
[17:02:18] [DEBUG] [CombatEngine] Dealing 23 to Entity(0xABCD)
2. Core Types
Type | Role |
---|---|
Logger |
Thin wrapper, created via Logger.Create<T>() or Logger.Create(string tag) |
LogLevel |
Enum: Trace , Debug , Info , Warn , Error , Fatal |
LogTags |
Static class of common subsystem tags (Managers , Engines , DB , …) |
Logger
public sealed class Logger
{
public void Log(LogLevel lvl, string msg, params object?[] args);
public void Trace(string msg, params object?[] args);
public void Debug(string msg, params object?[] args);
public void Info (string msg, params object?[] args);
public void Warn (string msg, params object?[] args);
public void Error(string msg, params object?[] args);
public void Fatal(string msg, params object?[] args);
}
3. Tag‑Based Filtering
Logger
instances can inject an optional tag; sinks may decide to ignore or
format differently.
var Log = Logger.Create<DatabaseManager>(LogTags.Databases);
Log.Info("Loaded {} entries", count);
4. High‑Performance Tips
- Prefer param string concat, will avoid string manipulation if the log level is disabled:
Log.Debug("Player {} killed {}", player.Id, enemy.Name);
- Wrap hot‑loop logs in
if (Log.IsDebugEnabled)
guards.
TL;DR
Logger.Create<T>()
→ log in 1 line.- Tag & level filters keep output readable.