AxibugEmuOnline/AxibugEmuOnline.Client/Assets/MyNes.Core/Tracer.cs

77 lines
2.4 KiB
C#
Raw Normal View History

2024-07-03 18:15:28 +08:00
#define TRACE
using System;
2024-07-04 10:41:48 +08:00
using UnityEngine;
2024-07-03 18:15:28 +08:00
2024-07-03 18:22:22 +08:00
namespace MyNes.Core
2024-07-03 18:15:28 +08:00
{
2024-07-03 18:22:22 +08:00
public sealed class Tracer
{
2024-07-04 10:41:48 +08:00
public static event EventHandler<TracerEventArgs> EventRaised;
2024-07-03 18:15:28 +08:00
2024-07-04 10:41:48 +08:00
public static void WriteLine(string message)
{
Tracer.EventRaised?.Invoke(null, new TracerEventArgs(message, TracerStatus.Normal));
Debug.Log(message);
}
2024-07-03 18:15:28 +08:00
2024-07-04 10:41:48 +08:00
public static void WriteLine(string message, string category)
{
Tracer.EventRaised?.Invoke(null, new TracerEventArgs($"{category}: {message}", TracerStatus.Normal));
Debug.Log(message);
}
2024-07-03 18:15:28 +08:00
2024-07-04 10:41:48 +08:00
public static void WriteLine(string message, TracerStatus status)
{
Tracer.EventRaised?.Invoke(null, new TracerEventArgs(message, status));
2024-07-04 21:06:41 +08:00
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;
}
2024-07-04 10:41:48 +08:00
}
2024-07-03 18:15:28 +08:00
2024-07-04 10:41:48 +08:00
public static void WriteLine(string message, string category, TracerStatus status)
{
Tracer.EventRaised?.Invoke(null, new TracerEventArgs($"{category}: {message}", status));
2024-07-04 21:06:41 +08:00
WriteLine($"{category}:{message}", status);
2024-07-04 10:41:48 +08:00
}
2024-07-03 18:15:28 +08:00
2024-07-04 10:41:48 +08:00
public static void WriteError(string message)
{
WriteLine(message, TracerStatus.Error);
}
2024-07-03 18:15:28 +08:00
2024-07-04 10:41:48 +08:00
public static void WriteError(string message, string category)
{
WriteLine(message, category, TracerStatus.Error);
}
2024-07-03 18:15:28 +08:00
2024-07-04 10:41:48 +08:00
public static void WriteWarning(string message)
{
WriteLine(message, TracerStatus.Warning);
}
2024-07-03 18:15:28 +08:00
2024-07-04 10:41:48 +08:00
public static void WriteWarning(string message, string category)
{
WriteLine(message, category, TracerStatus.Warning);
}
2024-07-03 18:15:28 +08:00
2024-07-04 10:41:48 +08:00
public static void WriteInformation(string message)
{
WriteLine(message, TracerStatus.Infromation);
}
2024-07-03 18:15:28 +08:00
2024-07-04 10:41:48 +08:00
public static void WriteInformation(string message, string category)
{
WriteLine(message, category, TracerStatus.Infromation);
}
2024-07-03 18:22:22 +08:00
}
2024-07-03 15:40:13 +08:00
}