-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConsoleHandler.cs
47 lines (43 loc) · 1016 Bytes
/
ConsoleHandler.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetLog.Logging
{
public class ConsoleHandler : Handler
{
private bool consoleDebug;
public new bool ConsoleDebug
{
get { return consoleDebug; }
set { consoleDebug = value; }
}
public ConsoleHandler()
{
Formatter = new StreamFormatter(false, true, false);
}
public override void Close() {
}
public override void Flush() {
Console.Out.Flush();
}
public override void Publish( LogRecord rec ) {
// stop now if not loggable
if (consoleDebug)
Console.WriteLine("rec level: " + rec.Level + ", our Level: " + this.Level);
if ( rec.Level.IntValue < this.Level.IntValue || this.Level == Level.OFF)
{
return;
}
lock( this ) {
rec.SequenceNumber = NextSequence;
if( HavePrefix )
Console.Write( Prefix );
Console.Write(this.Formatter.format(rec));
if ( HaveSuffix )
Console.Write( Suffix );
}
}
}
}