| name | oxgkit-unity-skill |
| description | Use when developing, reviewing, or debugging Unity projects that use OxGKit.LoggingSystem, including declaring loggers with [LoggerName] and the Logging base class, Logging.Print/PrintInfo/PrintWarning/PrintError/PrintException calls, the LoggingLauncher prefab and LoggerConfig.dat (StreamingAssets) configuration, LogLevel/LogColor rules, the OXGKIT_LOGGER_ON build symbol, runtime reconfiguration (ConfigureLogger/SetLoggersConfig), and HybridCLR AOT/Hotfix logger initialization. |
OxGKit.LoggingSystem Unity Skill
Purpose
Make the agent behave like an experienced OxGKit.LoggingSystem user. LoggingSystem is a standalone logging module (UPM package com.michaelo.oxgkit.loggingsystem) with named loggers, per-logger and global on/off + level + color control, and an encrypted/plaintext runtime config file for tuning logs on device without rebuilding.
First response rules
- Reply in the user's language; keep code and identifiers in English.
- Start with the conclusion, then implementation details.
- Before writing code, verify APIs against the installed package source (
Library/PackageCache/com.michaelo.oxgkit.loggingsystem@* or Assets/OxGKit/LoggingSystem/Scripts when embedded). Do not invent APIs; if a member is not listed here, confirm it in the source first.
- For player builds, always check whether the
OXGKIT_LOGGER_ON scripting define symbol is set — without it all logging is stripped from builds (the Editor works without it).
Install
- UPM git URL:
https://github.com/michael811125/OxGKit.git?path=Assets/OxGKit/LoggingSystem/Scripts
- Auto dependency:
com.domybest.lwmybox (LWMyBox, inspector attributes).
- Samples (Package Manager > OxGKit.LoggingSystem > Samples):
LoggingLauncher Prefab (bootstrap prefab), LoggingSystem Demo, AI Agent Skills (this skill).
Core concepts
- A logger is a class inheriting
Logging, named by [LoggerName("Name")] (falls back to the class name when the attribute is missing).
LoggingLauncher is a MonoBehaviour that discovers/initializes loggers and loads their settings. Import the LoggingLauncher Prefab sample and drop it into the boot scene once (initLoggersOnAwake is on by default).
LoggerConfig.dat in StreamingAssets overrides the inspector settings at runtime, so QA can toggle logs on device. Created via right-click Create/OxGKit/Logging System/[JSON - Plaintext] or [BYTES - Cipher] Create LoggerConfig.dat (In StreamingAssets); convertible both ways via Assets/OxGKit/Logging System/Convert LoggerConfig.dat (BYTES [Cipher] <-> JSON [Plaintext]). Ship releases with the cipher format. The file name, extension, and cipher key are customizable through the LoggingSettings asset (v1.4.0+; older versions used loggersconfig.conf).
- A log call is emitted only when the global (master) settings AND the per-logger settings both allow it (bitwise intersection for levels; see tables below).
Core API (verified)
using OxGKit.LoggingSystem;
[LoggerName("App.Runtime")]
public class RuntimeLogger : Logging
{
public RuntimeLogger() { }
}
[LoggerName("App.Runtime", true)]
public class OverrideRuntimeLogger : Logging
{
public OverrideRuntimeLogger() { }
public override void Log(object message) { UnityEngine.Debug.Log("[Override] " + message); }
}
Logging.Print<RuntimeLogger>("debug message");
Logging.PrintInfo<RuntimeLogger>("info message");
Logging.PrintWarning<RuntimeLogger>("warning message");
Logging.PrintError<RuntimeLogger>("error message");
Logging.PrintException<RuntimeLogger>(exception);
LoggingLauncher static API:
LoggingLauncher.InitLoggers();
LoggingLauncher.CreateLogger<TLogging>();
LoggingLauncher.ClearLoggers();
LoggingLauncher.TryInitLoggers();
LoggingLauncher.TryLoadLoggers();
LoggingLauncher.ToggleMasterLogging(true);
LoggingLauncher.LevelMasterLogging(LogLevel.All);
LoggingLauncher.ColorMasterLogging(LogColor.EditorOnly);
LoggingLauncher.ConfigureLogger("App.Runtime", true, LogLevel.LogWarning | LogLevel.LogError);
LoggingLauncher.ConfigureAllLoggers(true, LogLevel.All, LogColor.EditorOnly);
LoggingLauncher.SetLoggersConfig(new LoggersConfig(
new LoggerSettings("App.Runtime", true, LogLevel.All)
));
Enums:
[Flags] LogLevel { Off, LogDebug, LogInfo, LogWarning, LogError, LogException, All }
LogColor { Disabled, Enabled, EditorOnly }
ConfigFileType { Json, Bytes }
Level and color resolution
Levels — a level outputs only when both Global (G) and Per-logger (P) contain it (G ∩ P):
| Global (G) | Per-logger (P) | Effective |
|---|
| Off | any | none |
| any | Off | none |
| All | All | all levels |
| All | single Px | Px |
| single Gx | All | Gx |
| set G | set P | G ∩ P (none if empty) |
Colors — effective mode is the more restrictive of the two; EditorOnly colors in the Editor but not in players:
| Global | Per-logger | Effective |
|---|
| Disabled | any | Disabled |
| Enabled | Enabled | Enabled |
| Enabled/EditorOnly | EditorOnly (or vice versa) | EditorOnly |
Standard setup flow
- Import the
LoggingLauncher Prefab sample; put the prefab in the boot scene (once).
- Declare
[LoggerName] logger classes near each subsystem.
- Press Play — loggers are auto-discovered on Awake (
initLoggersOnAwake), settings load from StreamingAssets/LoggerConfig.dat when present.
- Add
OXGKIT_LOGGER_ON to Scripting Define Symbols for any build that must log.
- To tune logs on device, edit/replace
LoggerConfig.dat (convert to JSON for hand editing, back to BYTES for release).
HybridCLR (AOT + Hotfix) flow
Auto discovery scans assemblies and may miss hotfix-loaded loggers, so:
- Uncheck
Initialize On Awake on the LoggingLauncher prefab.
- In the AOT (main) startup:
LoggingLauncher.CreateLogger<TAotLogger>() for every AOT logger.
- In the hotfix startup:
CreateLogger<THotfixLogger>() for every hotfix logger.
- Call
LoggingLauncher.TryLoadLoggers() after creating loggers (each time the logger set changes).
- Give every logger a public default constructor (
Activator.CreateInstance is used).
Rules & pitfalls
- Adding or removing a logger at runtime requires
LoggingLauncher.TryLoadLoggers() to reload settings.
- README/older docs may show
LoggerSetting; the actual class is LoggerSettings.
Logging.Print<T> maps to LogDebug; PrintInfo to LogInfo, etc. Choose levels so release builds can keep only LogWarning | LogError | LogException.
- Do not wrap Logging calls in your own
#if guards for players; the package already compiles them out without OXGKIT_LOGGER_ON.
- The config file in
StreamingAssets is loaded via web request (works on Android/WebGL); if absent, inspector/default settings apply.
Verify
- Editor: enter Play mode and confirm
[LoggingSystem] is Initialized. appears and logger output respects the launcher settings.
- Player: build with
OXGKIT_LOGGER_ON, then toggle levels via LoggerConfig.dat and re-run to confirm filtering.