@@ -124,7 +124,7 @@ public void LogInfo(string message, params object[] args) =>
124124
125125 public void LogUIWarning ( string message , params object [ ] args )
126126 {
127- uiWarnings . Add ( GetFormattedMessage ( message , args ) ) ;
127+ uiWarnings . Add ( FormatMessage ( message , args ) ) ;
128128 LogWarning ( message , args ) ;
129129 }
130130
@@ -137,22 +137,6 @@ public void WriteUIWarnings(string outputFolder)
137137 }
138138 }
139139
140- private string GetFormattedMessage ( string message , params object [ ] args )
141- {
142- var finalMessage = message ;
143- if ( args is not null && args . Length > 0 )
144- {
145- finalMessage = string . Format ( CultureInfo . CurrentCulture , finalMessage ?? string . Empty , args ) ;
146- }
147-
148- if ( IncludeTimestamp )
149- {
150- finalMessage = string . Format ( CultureInfo . CurrentCulture , "{0} {1}" , DateTime . Now . ToString ( "HH:mm:ss.FFF" ,
151- CultureInfo . InvariantCulture ) , finalMessage ) ;
152- }
153- return finalMessage ;
154- }
155-
156140 private void FlushOutput ( )
157141 {
158142 Debug . Assert ( isOutputSuspended , "Not expecting FlushOutput to be called unless output is currently suspended" ) ;
@@ -170,7 +154,7 @@ private void FlushOutput()
170154 /// Formats a message and writes or records it.
171155 /// </summary>
172156 private void Write ( MessageType messageType , string message , params object [ ] args ) =>
173- WriteFormatted ( messageType , GetFormattedMessage ( message , args ) ) ;
157+ WriteFormatted ( messageType , FormatAndTimestampMessage ( message , args ) ) ;
174158
175159 /// <summary>
176160 /// Either writes the message to the output stream, or records it
@@ -196,6 +180,21 @@ private void WriteFormatted(MessageType messageType, string formatted)
196180 }
197181 }
198182
183+ private string FormatAndTimestampMessage ( string message , params object [ ] args )
184+ {
185+ var formatted = FormatMessage ( message , args ) ;
186+ if ( IncludeTimestamp )
187+ {
188+ formatted = string . Format ( CultureInfo . CurrentCulture , "{0} {1}" , DateTime . Now . ToString ( "HH:mm:ss.FFF" , CultureInfo . InvariantCulture ) , formatted ) ;
189+ }
190+ return formatted ;
191+ }
192+
193+ private static string FormatMessage ( string message , params object [ ] args ) =>
194+ args is not null && args . Length > 0
195+ ? string . Format ( CultureInfo . CurrentCulture , message ?? string . Empty , args )
196+ : message ;
197+
199198 private static ConsoleColor GetConsoleColor ( MessageType messageType ) =>
200199 messageType switch
201200 {
0 commit comments