Files
trail-into-darkness/Packages/com.jovian.ingame-logging/Runtime/InGameLogger.cs
2026-04-05 22:37:09 +02:00

37 lines
1.1 KiB
C#

using System.Runtime.CompilerServices;
namespace Jovian.InGameLogging {
public readonly struct InGameLogger {
private readonly IGameLogStore store;
private readonly LogChannel channel;
public InGameLogger(IGameLogStore store, LogChannel channel) {
this.store = store;
this.channel = channel;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Log(string message) {
store.Add(channel, message);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Log(string message, string hexColor) {
var prefix = hexColor.Length > 0 && hexColor[0] == '#' ? "" : "#";
store.Add(channel, $"<color={prefix}{hexColor}>{message}</color>");
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enable() {
store.EnableChannel(channel);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Disable() {
store.DisableChannel(channel);
}
public bool IsEnabled => store.IsChannelEnabled(channel);
}
}