generated from Raicuparta/ow-mod-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
OWConsoleLogger.cs
43 lines (34 loc) · 1.3 KB
/
OWConsoleLogger.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using DiscordRPC.Logging;
using OWML.Common;
using OWML.Logging;
namespace OWRichPresence
{
public class OWConsoleLogger : ILogger
{
public MessageType Type { get; set; }
public LogLevel Level
{
get => Type.OWMLToDiscord();
set => Type = value.DiscordToOWML();
}
public OWConsoleLogger(MessageType type)
{
this.Type = type;
}
public OWConsoleLogger(LogLevel level)
{
this.Level = level;
}
private static string Format(string message, params object[] args)
{
if (args != null && args.Length > 0)
return string.Format(message, args);
else
return message;
}
public void Trace(string message, params object[] args) => OWRichPresence.WriteLine(Format(message, args), MessageType.Debug);
public void Info(string message, params object[] args) => OWRichPresence.WriteLine(Format(message, args), MessageType.Info);
public void Warning(string message, params object[] args) => OWRichPresence.WriteLine(Format(message, args), MessageType.Warning);
public void Error(string message, params object[] args) => OWRichPresence.WriteLine(Format(message, args), MessageType.Error);
}
}