AxibugEmuOnline/AxibugEmuOnline.Client/Assets/MyNes.Core/Tracer.cs
2024-07-16 17:46:07 +08:00

77 lines
2.4 KiB
C#

#define TRACE
using System;
using UnityEngine;
namespace MyNes.Core
{
public sealed class Tracer
{
public static event EventHandler<TracerEventArgs> EventRaised;
public static void WriteLine(string message)
{
Tracer.EventRaised?.Invoke(null, new TracerEventArgs(message, TracerStatus.Normal));
//Debug.Log(message);
}
public static void WriteLine(string message, string category)
{
Tracer.EventRaised?.Invoke(null, new TracerEventArgs($"{category}: {message}", TracerStatus.Normal));
//Debug.Log(message);
}
public static void WriteLine(string message, TracerStatus status)
{
Tracer.EventRaised?.Invoke(null, new TracerEventArgs(message, status));
switch (status)
{
case TracerStatus.Error: Debug.LogError(message); break;
case TracerStatus.Infromation:
case TracerStatus.Normal:
Debug.Log(message);
break;
case TracerStatus.Warning:
Debug.LogWarning(message);
break;
}
}
public static void WriteLine(string message, string category, TracerStatus status)
{
Tracer.EventRaised?.Invoke(null, new TracerEventArgs($"{category}: {message}", status));
WriteLine($"{category}:{message}", status);
}
public static void WriteError(string message)
{
WriteLine(message, TracerStatus.Error);
}
public static void WriteError(string message, string category)
{
WriteLine(message, category, TracerStatus.Error);
}
public static void WriteWarning(string message)
{
WriteLine(message, TracerStatus.Warning);
}
public static void WriteWarning(string message, string category)
{
WriteLine(message, category, TracerStatus.Warning);
}
public static void WriteInformation(string message)
{
WriteLine(message, TracerStatus.Infromation);
}
public static void WriteInformation(string message, string category)
{
WriteLine(message, category, TracerStatus.Infromation);
}
}
}