@@ -11,21 +11,25 @@ public class LogFile : HostIOSubscriberBase
11
11
{
12
12
#region Fields
13
13
14
- private const string DateTimeFormat = "r " ;
14
+ // private string DateTimeFormat = "dd-MMM-yyyy - HH:mm:ss ";
15
15
private readonly string fileName ;
16
16
private readonly string path ;
17
17
18
18
#endregion
19
19
20
20
#region Constructors and Destructors
21
21
22
- public LogFile ( string filename , StreamType streams = StreamType . All , ScriptBlock errorCallback = null )
22
+ public LogFile ( string filename ,
23
+ StreamType streams = StreamType . All ,
24
+ ScriptBlock errorCallback = null ,
25
+ string dateTimeFormat = "r" )
23
26
{
24
27
fileName = System . IO . Path . GetFileName ( filename ) ;
25
28
path = System . IO . Path . GetDirectoryName ( filename ) ;
26
29
27
30
Streams = streams ;
28
31
ErrorCallback = errorCallback ;
32
+ DateTimeFormat = dateTimeFormat ;
29
33
}
30
34
31
35
#endregion
@@ -41,6 +45,8 @@ public string Path
41
45
42
46
public StreamType Streams { get ; set ; }
43
47
48
+ public string DateTimeFormat { get ; set ; }
49
+
44
50
#endregion
45
51
46
52
#region Public Methods and Operators
@@ -65,7 +71,7 @@ public override void WriteDebug(string message)
65
71
CheckDirectory ( ) ;
66
72
if ( message != String . Empty )
67
73
{
68
- message = String . Format ( "{0,-29 } - [D] {1}" , DateTime . UtcNow . ToString ( DateTimeFormat ) , message ) ;
74
+ message = String . Format ( "{0,-18 } - [D] {1}" , DateTime . UtcNow . ToString ( DateTimeFormat ) , message ) ;
69
75
}
70
76
71
77
File . AppendAllText ( System . IO . Path . Combine ( path , fileName ) , message ) ;
@@ -92,7 +98,7 @@ public override void WriteError(string message)
92
98
CheckDirectory ( ) ;
93
99
if ( message . Trim ( ) != String . Empty )
94
100
{
95
- message = String . Format ( "{0,-29 } - [E] {1}" , DateTime . UtcNow . ToString ( DateTimeFormat ) , message ) ;
101
+ message = String . Format ( "{0,-18 } - [E] {1}" , DateTime . UtcNow . ToString ( DateTimeFormat ) , message ) ;
96
102
}
97
103
98
104
File . AppendAllText ( System . IO . Path . Combine ( path , fileName ) , message ) ;
@@ -119,7 +125,7 @@ public override void WriteOutput(string message)
119
125
CheckDirectory ( ) ;
120
126
if ( message . Trim ( ) != String . Empty )
121
127
{
122
- message = String . Format ( "{0,-29 } - {1}" , DateTime . UtcNow . ToString ( DateTimeFormat ) , message ) ;
128
+ message = String . Format ( "{0,-18 } - {1}" , DateTime . UtcNow . ToString ( DateTimeFormat ) , message ) ;
123
129
}
124
130
125
131
File . AppendAllText ( System . IO . Path . Combine ( path , fileName ) , message ) ;
@@ -146,7 +152,7 @@ public override void WriteVerbose(string message)
146
152
CheckDirectory ( ) ;
147
153
if ( message . Trim ( ) != String . Empty )
148
154
{
149
- message = String . Format ( "{0,-29 } - [V] {1}" , DateTime . UtcNow . ToString ( DateTimeFormat ) , message ) ;
155
+ message = String . Format ( "{0,-18 } - [V] {1}" , DateTime . UtcNow . ToString ( DateTimeFormat ) , message ) ;
150
156
}
151
157
152
158
File . AppendAllText ( System . IO . Path . Combine ( path , fileName ) , message ) ;
@@ -173,7 +179,7 @@ public override void WriteWarning(string message)
173
179
CheckDirectory ( ) ;
174
180
if ( message . Trim ( ) != String . Empty )
175
181
{
176
- message = String . Format ( "{0,-29 } - [W] {1}" , DateTime . UtcNow . ToString ( DateTimeFormat ) , message ) ;
182
+ message = String . Format ( "{0,-18 } - [W] {1}" , DateTime . UtcNow . ToString ( DateTimeFormat ) , message ) ;
177
183
}
178
184
179
185
File . AppendAllText ( System . IO . Path . Combine ( path , fileName ) , message ) ;
0 commit comments