Space-Smash-Out/Assets/Logging/UnityDebugAppender.cs
Jakob Feldmann 64162cb4a1 feat: whole project restructuring
This can be seen as the initial state of the project after the released demo.

The changes include:
- New ship models
- Singleton manager structure to keep project scaleable in the future
     - Managing players, their settings, character choices, statistics, match setups, controls etc. in a separate decoupled scene
- Main menu with transitions to the arena scene
- Beginnings of a custom audio solution
- Logging with Log4Net

It is really a complete overhaul of the projects structure and management.
2024-04-01 23:06:39 +02:00

24 lines
710 B
C#

using log4net.Appender;
using log4net.Core;
using UnityEngine;
public class UnityDebugAppender : AppenderSkeleton
{
protected override void Append(LoggingEvent loggingEvent)
{
string message = RenderLoggingEvent(loggingEvent);
string colorTag = GetColorTag(loggingEvent.Level);
Debug.Log($"<b>{colorTag}</b> {message}");
}
private string GetColorTag(Level level)
{
// Map log levels to colors (customize as needed)
switch (level.Name)
{
case "DEBUG": return "<color=green>Debug: </color>";
case "INFO": return @"<color=black>Info: </color>";
case "WARN": return @"<color=yellow>Warning: </color>";
case "ERROR": return @"<color=red>Error: </color>";
default: return "";
}
}
}