NTP Analyzer
0.8.2
Analyze the operation of time servers
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
LogGroup.cs
Go to the documentation of this file.
1
//
2
// Copyright (c) 2013-2017 Carsten Sonne Larsen <cs@innolan.net>
3
//
4
// Permission is hereby granted, free of charge, to any person obtaining a copy
5
// of this software and associated documentation files (the "Software"), to deal
6
// in the Software without restriction, including without limitation the rights
7
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
// copies of the Software, and to permit persons to whom the Software is
9
// furnished to do so, subject to the following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included in
12
// all copies or substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
// THE SOFTWARE.
21
22
using
System
;
23
using
System
.Collections;
24
using
System
.Collections.Generic;
25
using
System
.Linq;
26
27
namespace
Ntp
.Common.Log
28
{
29
public
sealed
class
LogGroup
:
LogBase
, IEnumerable<LogBase>
30
{
31
internal
LogGroup
()
32
: base(
Severity
.
Trace
)
33
{
34
logs =
new
List<LogBase>();
35
}
36
37
private
readonly List<LogBase>
logs
;
38
39
private
LogBase
SysLog
40
{
41
get
42
{
43
return
logs.
44
Where(l => l.IsSysLog).
45
OrderBy(l => l.Threshold).
46
FirstOrDefault();
47
}
48
}
49
50
private
LogBase
ConsoleLog
51
{
52
get
53
{
54
return
logs.
55
Where(l => l is
ConsoleLog
).
56
OrderBy(l => l.Threshold).
57
FirstOrDefault();
58
}
59
}
60
61
public
IEnumerator<LogBase>
GetEnumerator
()
62
{
63
return
logs.GetEnumerator();
64
}
65
66
IEnumerator IEnumerable.GetEnumerator()
67
{
68
return
GetEnumerator();
69
}
70
71
public
void
Add
(
LogBase
log)
72
{
73
var logGroup = log as
LogGroup
;
74
if
(logGroup != null)
75
{
76
logs.AddRange(logGroup);
77
}
78
else
79
{
80
logs.
Add
(log);
81
}
82
}
83
84
public
override
void
Close
()
85
{
86
foreach
(var log
in
logs)
87
log.Close();
88
}
89
90
public
override
void
Initialize
()
91
{
92
foreach
(var log
in
logs)
93
log.Initialize();
94
}
95
96
public
override
void
Resume
()
97
{
98
foreach
(var log
in
logs)
99
log.Resume();
100
}
101
102
public
override
void
Suspend
()
103
{
104
foreach
(var log
in
logs)
105
log.Suspend();
106
}
107
108
public
override
void
WriteLine
(
string
text,
Severity
severity)
109
{
110
SysLog
?.
WriteLine
(text, severity);
111
ConsoleLog
?.
WriteLine
(text, severity);
112
113
foreach
(var log
in
logs.Where(l => l is
FileLog
))
114
log.WriteLine(text, severity);
115
}
116
117
public
override
void
WriteLine
(Exception exception)
118
{
119
SysLog
?.
WriteLine
(exception);
120
ConsoleLog
?.
WriteLine
(exception);
121
122
foreach
(var log
in
logs.Where(l => l is
FileLog
))
123
log.WriteLine(exception);
124
}
125
126
public
override
void
WriteLine
(Exception exception,
Severity
severity)
127
{
128
SysLog
?.
WriteLine
(exception, severity);
129
ConsoleLog
?.
WriteLine
(exception, severity);
130
131
foreach
(var log
in
logs.Where(l => l is
FileLog
))
132
log.WriteLine(exception, severity);
133
}
134
}
135
}
Ntp.Common.Log.LogGroup.Add
void Add(LogBase log)
Definition:
LogGroup.cs:71
Ntp.Common.Log.LogGroup.Initialize
override void Initialize()
Definition:
LogGroup.cs:90
Ntp.Common.Log.LogGroup.WriteLine
override void WriteLine(string text, Severity severity)
Definition:
LogGroup.cs:108
Ntp.Common.Log.LogGroup.Suspend
override void Suspend()
Definition:
LogGroup.cs:102
Ntp.Common.Log.LogGroup.GetEnumerator
IEnumerator< LogBase > GetEnumerator()
Definition:
LogGroup.cs:61
Ntp.Common.Log.FileLog
Definition:
FileLog.cs:28
Ntp.Common.Log.LogGroup.WriteLine
override void WriteLine(Exception exception, Severity severity)
Definition:
LogGroup.cs:126
Ntp.Common.Log.LogGroup.logs
readonly List< LogBase > logs
Definition:
LogGroup.cs:37
Ntp.Common.Log.LogGroup
Definition:
LogGroup.cs:29
Ntp.Common.Log.LogGroup.LogGroup
LogGroup()
Definition:
LogGroup.cs:31
Ntp.Common.Log.LogBase
Definition:
LogBase.cs:26
Ntp
Ntp.Common.Log.LogGroup.WriteLine
override void WriteLine(Exception exception)
Definition:
LogGroup.cs:117
Ntp.Common.Log.Severity.Trace
System
Ntp.Common.Log.SysLog
Definition:
SysLog.cs:28
Ntp.Common.Log.ConsoleLog
Definition:
ConsoleLog.cs:27
Ntp.Common.Log.SysLog.WriteLine
override void WriteLine(Exception exception)
Definition:
SysLog.cs:71
Ntp.Common.Log.LogGroup.Resume
override void Resume()
Definition:
LogGroup.cs:96
Ntp.Common.Log.Severity
Severity
Definition:
Severity.cs:24
Ntp.Common.Log.TextLog.WriteLine
override void WriteLine(string text, Severity severity)
Definition:
TextLog.cs:86
Ntp.Common.Log.LogGroup.Close
override void Close()
Definition:
LogGroup.cs:84
Ntp.Common
Log
LogGroup.cs
Generated by
1.8.11