-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoggingSection.cs
54 lines (43 loc) · 1.14 KB
/
LoggingSection.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
using System;
using System.Collections.Generic;
namespace oftc_ircd_cs
{
public enum LogLevel
{
Trace = 0,
Debug,
Info,
Notice,
Warning,
Error,
Critical
}
public class LoggingSection : IConfigSection
{
public LogLevel Level;
public string Path { get; set; }
#region ConfigSection Members
public void SetDefaults()
{
Level = LogLevel.Info;
Path = "ircd.log";
}
public void Process(object o)
{
var section = o as Dictionary<string, object>;
if (section == null)
throw new Exception("config element is not an object as expected");
object tmp;
string tmpLevel = "info";
if (section.TryGetValue("log_level", out tmp))
tmpLevel = (string) tmp;
if (section.TryGetValue("log_path", out tmp))
Path = (string) tmp;
Level = (LogLevel) Enum.Parse(typeof (LogLevel), tmpLevel, true);
}
public void Verify()
{
}
#endregion
}
}