@@ -59,22 +59,34 @@ public void Log(LogLevel logLevel, string message, Exception exception = null, b
5959 }
6060 else
6161 {
62- // For system logs, we log to stdio with a prefix of LanguageWorkerConsoleLog.
63- // These are picked up by the Functions Host
64- _systemLogMsg . Append ( SystemLogPrefix ) . AppendLine ( "System Log: {" ) ;
65- if ( ! string . IsNullOrEmpty ( _requestId ) )
66- {
67- _systemLogMsg . AppendLine ( $ " Request-Id: { _requestId } ") ;
68- }
69- if ( ! string . IsNullOrEmpty ( _invocationId ) )
70- {
71- _systemLogMsg . AppendLine ( $ " Invocation-Id: { _invocationId } ") ;
72- }
73- _systemLogMsg . AppendLine ( $ " Log-Message: { message } ") . AppendLine ( "}" ) ;
62+ WriteSystemLog ( message , _systemLogMsg , _requestId , _invocationId ) ;
63+ }
64+ }
7465
75- Console . WriteLine ( _systemLogMsg . ToString ( ) ) ;
76- _systemLogMsg . Clear ( ) ;
66+ private static void WriteSystemLog ( string message , StringBuilder stringBuilder , string requestId , string invocationId )
67+ {
68+ stringBuilder = stringBuilder ?? new StringBuilder ( ) ;
69+
70+ // For system logs, we log to stdio with a prefix of LanguageWorkerConsoleLog.
71+ // These are picked up by the Functions Host
72+ stringBuilder . Append ( SystemLogPrefix ) . AppendLine ( "System Log: {" ) ;
73+ if ( ! string . IsNullOrEmpty ( requestId ) )
74+ {
75+ stringBuilder . AppendLine ( $ " Request-Id: { requestId } ") ;
7776 }
77+ if ( ! string . IsNullOrEmpty ( invocationId ) )
78+ {
79+ stringBuilder . AppendLine ( $ " Invocation-Id: { invocationId } ") ;
80+ }
81+ stringBuilder . AppendLine ( $ " Log-Message: { message } ") . AppendLine ( "}" ) ;
82+
83+ Console . WriteLine ( stringBuilder . ToString ( ) ) ;
84+ stringBuilder . Clear ( ) ;
85+ }
86+
87+ internal static void WriteSystemLog ( string message )
88+ {
89+ WriteSystemLog ( message , stringBuilder : null , requestId : null , invocationId : null ) ;
7890 }
7991 }
8092}
0 commit comments