Rizu/Rizu.Core/Logger.cs

58 lines
1.4 KiB
C#
Raw Normal View History

2024-05-21 22:29:18 +02:00
using System.Diagnostics;
using JetBrains.Annotations;
namespace Rizu.Core;
2024-05-21 22:29:18 +02:00
// UnityEngine.Debug logs don't show up in BepInEx logs for some reason
public static class Logger
{
private static readonly string LogPrefix = "[Rizu]";
[Conditional("DEBUG")]
public static void Debug(string msg)
{
Log("DEBUG", msg);
}
[Conditional("DEBUG")]
[StringFormatMethod("format")]
public static void Debug(string format, params object[] args)
{
Log("DEBUG", format, args);
}
public static void Info(string msg)
{
Log("INFO", msg);
}
[StringFormatMethod("format")]
public static void Info(string format, params object[] args)
{
Log("INFO", format, args);
}
public static void Error(string msg)
{
Log("ERROR", msg);
}
[StringFormatMethod("format")]
public static void Error(string format, params object[] args)
{
Log("ERROR", format, args);
}
private static void Log(string level, string msg)
{
System.Console.WriteLine($"{LogPrefix} [{level}] {msg}");
}
[StringFormatMethod("format")]
private static void Log(string level, string format, params object[] args)
{
System.Console.WriteLine($"{LogPrefix} [{level}] {format}", args);
}
}