UnityConsoleLoggerConfig - jimdroberts/FishMMO GitHub Wiki
Configuration for the Unity Console Logger. Controls log level filtering, color mapping, and enablement for routing messages through FishMMO.Logging.Log to the Unity console in development and debugging scenarios.
-
public string Type { get; set; }
The type name of this config (for serialization and identification).
-
public string LoggerType { get; set; }
The logger type name (for serialization and identification).
-
public bool Enabled { get; set; }
Indicates whether this logger is enabled. If false, no messages will be sent to the Unity console via this logger.
-
public HashSet AllowedLevels { get; set; }
The collection of LogLevels that this logger is allowed to process. Only messages with levels present in this collection will be forwarded to the Unity console.
-
public Dictionary<LogLevel, string> LogLevelColors { get; set; }
Defines Unity Rich Text color strings for each LogLevel. Keys are LogLevel enum values, values are Unity color names (e.g., "red", "green") or hex codes (e.g., "#FF0000").
-
public UnityConsoleLoggerConfig()
Initializes a new instance of the UnityConsoleLoggerConfig class with default type and logger type names.
- Create an instance of
UnityConsoleLoggerConfig
and configure the desired log levels, colors, and enablement. - Pass the config to a
UnityConsoleLogger
instance to control logging behavior in the Unity console. - Adjust
AllowedLevels
andLogLevelColors
to match your project's logging needs and color preferences.
// Example 1: Creating and configuring UnityConsoleLoggerConfig
var config = new UnityConsoleLoggerConfig
{
Enabled = true,
AllowedLevels = new HashSet<LogLevel> { LogLevel.Info, LogLevel.Warning, LogLevel.Error },
LogLevelColors = new Dictionary<LogLevel, string>
{
{ LogLevel.Info, "white" },
{ LogLevel.Warning, "yellow" },
{ LogLevel.Error, "red" }
}
};
// Example 2: Using the config with UnityConsoleLogger
var logger = new UnityConsoleLogger(config);
- Use
AllowedLevels
to filter out unnecessary log messages and reduce console noise. - Customize
LogLevelColors
for clear visual distinction between log severities. - Set
Enabled
to false in production builds to avoid unnecessary console output. - Use type and logger type names for serialization and configuration management.