added code from unity
This commit is contained in:
36
Runtime/InGameLogger.cs
Normal file
36
Runtime/InGameLogger.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user