-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogging.cs
67 lines (54 loc) · 1.26 KB
/
Logging.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.IO;
namespace oftc_ircd_cs
{
public class Logging
{
private static TextWriter writer;
public static LoggingSection Conf { get; set; }
public static void Init()
{
Conf = new LoggingSection();
Config.AddSection("logging", Conf);
}
public static void Start()
{
writer = new StreamWriter(Conf.Path, true);
}
private static void Log(LogLevel level, string format)
{
if (level < Conf.Level)
return;
writer.WriteLine("{0:u} - (core) [{1}] - {2}", DateTime.Now, level.ToString(), format);
writer.Flush();
}
public static void Trace(string format)
{
Log(LogLevel.Trace, format);
}
public static void Debug(string format)
{
Log(LogLevel.Debug, format);
}
public static void Info(string format)
{
Log(LogLevel.Info, format);
}
public static void Notice(string format)
{
Log(LogLevel.Notice, format);
}
public static void Warning(string format)
{
Log(LogLevel.Warning, format);
}
public static void Error(string format)
{
Log(LogLevel.Error, format);
}
public static void Critical(string format)
{
Log(LogLevel.Critical, format);
}
}
}