@@ -11,21 +11,25 @@ public class LogFile : HostIOSubscriberBase
1111 {
1212 #region Fields
1313
14- private const string DateTimeFormat = "r " ;
14+ // private string DateTimeFormat = "dd-MMM-yyyy - HH:mm:ss ";
1515 private readonly string fileName ;
1616 private readonly string path ;
1717
1818 #endregion
1919
2020 #region Constructors and Destructors
2121
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" )
2326 {
2427 fileName = System . IO . Path . GetFileName ( filename ) ;
2528 path = System . IO . Path . GetDirectoryName ( filename ) ;
2629
2730 Streams = streams ;
2831 ErrorCallback = errorCallback ;
32+ DateTimeFormat = dateTimeFormat ;
2933 }
3034
3135 #endregion
@@ -41,6 +45,8 @@ public string Path
4145
4246 public StreamType Streams { get ; set ; }
4347
48+ public string DateTimeFormat { get ; set ; }
49+
4450 #endregion
4551
4652 #region Public Methods and Operators
@@ -65,7 +71,7 @@ public override void WriteDebug(string message)
6571 CheckDirectory ( ) ;
6672 if ( message != String . Empty )
6773 {
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 ) ;
6975 }
7076
7177 File . AppendAllText ( System . IO . Path . Combine ( path , fileName ) , message ) ;
@@ -92,7 +98,7 @@ public override void WriteError(string message)
9298 CheckDirectory ( ) ;
9399 if ( message . Trim ( ) != String . Empty )
94100 {
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 ) ;
96102 }
97103
98104 File . AppendAllText ( System . IO . Path . Combine ( path , fileName ) , message ) ;
@@ -119,7 +125,7 @@ public override void WriteOutput(string message)
119125 CheckDirectory ( ) ;
120126 if ( message . Trim ( ) != String . Empty )
121127 {
122- message = String . Format ( "{0,-29 } - {1}" , DateTime . UtcNow . ToString ( DateTimeFormat ) , message ) ;
128+ message = String . Format ( "{0,-18 } - {1}" , DateTime . UtcNow . ToString ( DateTimeFormat ) , message ) ;
123129 }
124130
125131 File . AppendAllText ( System . IO . Path . Combine ( path , fileName ) , message ) ;
@@ -146,7 +152,7 @@ public override void WriteVerbose(string message)
146152 CheckDirectory ( ) ;
147153 if ( message . Trim ( ) != String . Empty )
148154 {
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 ) ;
150156 }
151157
152158 File . AppendAllText ( System . IO . Path . Combine ( path , fileName ) , message ) ;
@@ -173,7 +179,7 @@ public override void WriteWarning(string message)
173179 CheckDirectory ( ) ;
174180 if ( message . Trim ( ) != String . Empty )
175181 {
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 ) ;
177183 }
178184
179185 File . AppendAllText ( System . IO . Path . Combine ( path , fileName ) , message ) ;
0 commit comments