This repository was archived by the owner on Oct 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogEventArgs.cs
More file actions
75 lines (67 loc) · 2.12 KB
/
LogEventArgs.cs
File metadata and controls
75 lines (67 loc) · 2.12 KB
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
68
69
70
71
72
73
74
using System;
namespace Xevle.Logging
{
/// <summary>
/// Log event arguments.
/// </summary>
public class LogEventArgs : EventArgs
{
/// <summary>
/// Gets the timecode.
/// </summary>
/// <value>The timecode.</value>
public DateTime Timecode { get; private set; }
/// <summary>
/// Gets the level.
/// </summary>
/// <value>The level.</value>
public LogLevel Level { get; private set; }
/// <summary>
/// Gets the message.
/// </summary>
/// <value>The message.</value>
public string Message { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="T:Xevle.Logging.LogEventArgs"/> class.
/// </summary>
/// <param name="level">Level.</param>
/// <param name="message">Message.</param>
public LogEventArgs(LogLevel level, string message)
{
Timecode = DateTime.Now;
Level = level;
Message = message;
}
/// <summary>
/// Initializes a new instance of the <see cref="T:Xevle.Logging.LogEventArgs"/> class.
/// </summary>
/// <param name="e">E.</param>
public LogEventArgs(LogEventArgs e)
{
this.Timecode = e.Timecode;
this.Level = e.Level;
this.Message = e.Message;
}
/// <summary>
/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:Xevle.Logging.LogEventArgs"/>.
/// </summary>
/// <returns>A <see cref="T:System.String"/> that represents the current <see cref="T:Xevle.Logging.LogEventArgs"/>.</returns>
public override string ToString()
{
return string.Format("[{0:D4}.{1:D2}.{2:D2} {3:D2}:{4:D2}:{5:D2},{6:D3}] - {7} - {8}",
Timecode.Year, Timecode.Month, Timecode.Day,
Timecode.Hour, Timecode.Minute, Timecode.Second, Timecode.Millisecond,
(Level & LogLevel.CriticalToVerbose).ToString().ToUpper(), Message);
}
/// <summary>
/// Tos the shorten string.
/// </summary>
/// <returns>The shorten string.</returns>
public string ToShortenString()
{
return string.Format("[{0:D2}:{1:D2}:{2:D2},{3:D3}] - {4} - {5}",
Timecode.Hour, Timecode.Minute, Timecode.Second, Timecode.Millisecond,
(Level & LogLevel.CriticalToVerbose).ToString().ToUpper(), Message);
}
}
}