You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- implement flush on dispose, so that logs are flushed when process shuts down
- specify reader/writer usage of the channel
- Change the write to console path to use WriteAsync instead of WaitToWriteAsync
- Use TryComplete instead of Complete so that repeated completes do not throw
- fix bug where a line could be read from buffer but not written to output
"-1"=>Channel.CreateUnbounded<string>(),// buffer size of -1 indicates that buffer should be enabled but unbounded
40
-
"0"=>null,// buffer size of 0 indicates that buffer should be disabled
42
+
"-1"=>Channel.CreateUnbounded<string>(newUnboundedChannelOptions(){SingleReader=true,SingleWriter=false}),// buffer size of -1 indicates that buffer should be enabled but unbounded
43
+
"0"=>null,// buffer size of 0 indicates that buffer should be disabled
_ =>Channel.CreateBounded<string>(DefaultBufferSize),// default behavior is to use buffer with default size
45
+
_ =>Channel.CreateBounded<string>(newBoundedChannelOptions(DefaultBufferSize){SingleReader=true,SingleWriter=false}),// default behavior is to use buffer with default size
@@ -153,7 +154,7 @@ public void MultipleEventsWithTinyBuffer_WritesDirectlyToConsoleOnTimeout(bool b
153
154
// The first two messages are still stuck in the buffer. The third message will have been written to the console.
154
155
// We should also have a log for the timeout exception that occurred while waiting for the buffer to become available.
155
156
Assert.Equal(2,output.Length);
156
-
Assert.StartsWith("MS_FUNCTION_LOGS 2,,,,,LogUnhandledException,\"System.AggregateException: One or more errors occurred. (The operation has timed out.)",output[0]);
157
+
Assert.StartsWith("MS_FUNCTION_LOGS 2,,,,,LogUnhandledException,\"System.OperationCanceledException: The operation was canceled.",output[0]);
157
158
Assert.Equal($"MS_FUNCTION_LOGS 4,C37E3412-86D1-4B93-BC5A-A2AE09D26C2D,TestApp,TestFunction3,TestEvent,TestSource,\"These are the details, lots of details\",\"This is the summary, a great summary\",{ScriptHost.Version},{timestamp.ToString("O")},TestExceptionType,\"Test exception message, with details\",E2D5A6ED-4CE3-4CFD-8878-FD4814F0A1F3,3AD41658-1C4E-4C9D-B0B9-24F2BDAE2829,F0AAA9AD-C3A6-48B9-A75E-57BB280EBB53,TEST-CONTAINER,test-stamp,test-tenant,TestRuntimeSiteName,TestSlotName",output[1]);
158
159
}
159
160
@@ -175,7 +176,7 @@ public async Task MultipleEventsBatchedWithTinyBuffer_BlocksOnWriteOnBufferFull_
@@ -188,5 +189,72 @@ public async Task MultipleEventsBatchedWithTinyBuffer_BlocksOnWriteOnBufferFull_
188
189
Assert.Equal($"MS_FUNCTION_LOGS 4,C37E3412-86D1-4B93-BC5A-A2AE09D26C2D,TestApp,TestFunction2,TestEvent,TestSource,\"These are the details, lots of details\",\"This is the summary, a great summary\",{ScriptHost.Version},{timestamp.ToString("O")},TestExceptionType,\"Test exception message, with details\",E2D5A6ED-4CE3-4CFD-8878-FD4814F0A1F3,3AD41658-1C4E-4C9D-B0B9-24F2BDAE2829,F0AAA9AD-C3A6-48B9-A75E-57BB280EBB53,TEST-CONTAINER,test-stamp,test-tenant,TestRuntimeSiteName,TestSlotName",output[1]);
189
190
Assert.Equal($"MS_FUNCTION_LOGS 4,C37E3412-86D1-4B93-BC5A-A2AE09D26C2D,TestApp,TestFunction3,TestEvent,TestSource,\"These are the details, lots of details\",\"This is the summary, a great summary\",{ScriptHost.Version},{timestamp.ToString("O")},TestExceptionType,\"Test exception message, with details\",E2D5A6ED-4CE3-4CFD-8878-FD4814F0A1F3,3AD41658-1C4E-4C9D-B0B9-24F2BDAE2829,F0AAA9AD-C3A6-48B9-A75E-57BB280EBB53,TEST-CONTAINER,test-stamp,test-tenant,TestRuntimeSiteName,TestSlotName",output[2]);
generator.LogFunctionTraceEvent(LogLevel.Information,"C37E3412-86D1-4B93-BC5A-A2AE09D26C2D","TestApp","TestFunction1","TestEvent","TestSource","These are the details, lots of details","This is the summary, a great summary","TestExceptionType","Test exception message, with details","E2D5A6ED-4CE3-4CFD-8878-FD4814F0A1F3","3AD41658-1C4E-4C9D-B0B9-24F2BDAE2829","F0AAA9AD-C3A6-48B9-A75E-57BB280EBB53","TestRuntimeSiteName","TestSlotName",timestamp);
207
+
generator.LogFunctionTraceEvent(LogLevel.Information,"C37E3412-86D1-4B93-BC5A-A2AE09D26C2D","TestApp","TestFunction2","TestEvent","TestSource","These are the details, lots of details","This is the summary, a great summary","TestExceptionType","Test exception message, with details","E2D5A6ED-4CE3-4CFD-8878-FD4814F0A1F3","3AD41658-1C4E-4C9D-B0B9-24F2BDAE2829","F0AAA9AD-C3A6-48B9-A75E-57BB280EBB53","TestRuntimeSiteName","TestSlotName",timestamp);
208
+
awaitTask.Delay(TimeSpan.FromMilliseconds(20));
209
+
210
+
// We haven't released the semaphore yet, so nothing should have been written.
211
+
Assert.Equal(0,_consoleOut.Length);
212
+
213
+
vardisposeTask=Task.Run(consoleWriter.Dispose);
214
+
awaitTask.Delay(TimeSpan.FromMilliseconds(20));
215
+
216
+
// Dispose should be blocked on flushing the buffer, which is blocked on the semaphore.
217
+
Assert.False(disposeTask.IsCompleted);
218
+
219
+
controlledWriter.Semaphore.Release();
220
+
awaitdisposeTask;
221
+
222
+
// after being disposed, console writer should fall back to direct console write, just so that we don't get errors on logging paths
223
+
generator.LogFunctionTraceEvent(LogLevel.Information,"C37E3412-86D1-4B93-BC5A-A2AE09D26C2D","TestApp","TestFunction3","TestEvent","TestSource","These are the details, lots of details","This is the summary, a great summary","TestExceptionType","Test exception message, with details","E2D5A6ED-4CE3-4CFD-8878-FD4814F0A1F3","3AD41658-1C4E-4C9D-B0B9-24F2BDAE2829","F0AAA9AD-C3A6-48B9-A75E-57BB280EBB53","TestRuntimeSiteName","TestSlotName",timestamp);
224
+
225
+
usingvarsr=newStreamReader(_consoleOut);
226
+
_consoleOut.Position=0;
227
+
varoutput=sr.ReadToEnd().Trim().SplitLines();
228
+
229
+
Assert.Equal(3,output.Length);
230
+
231
+
Assert.Equal($"MS_FUNCTION_LOGS 4,C37E3412-86D1-4B93-BC5A-A2AE09D26C2D,TestApp,TestFunction1,TestEvent,TestSource,\"These are the details, lots of details\",\"This is the summary, a great summary\",{ScriptHost.Version},{timestamp.ToString("O")},TestExceptionType,\"Test exception message, with details\",E2D5A6ED-4CE3-4CFD-8878-FD4814F0A1F3,3AD41658-1C4E-4C9D-B0B9-24F2BDAE2829,F0AAA9AD-C3A6-48B9-A75E-57BB280EBB53,TEST-CONTAINER,test-stamp,test-tenant,TestRuntimeSiteName,TestSlotName",output[0]);
232
+
Assert.Equal($"MS_FUNCTION_LOGS 4,C37E3412-86D1-4B93-BC5A-A2AE09D26C2D,TestApp,TestFunction2,TestEvent,TestSource,\"These are the details, lots of details\",\"This is the summary, a great summary\",{ScriptHost.Version},{timestamp.ToString("O")},TestExceptionType,\"Test exception message, with details\",E2D5A6ED-4CE3-4CFD-8878-FD4814F0A1F3,3AD41658-1C4E-4C9D-B0B9-24F2BDAE2829,F0AAA9AD-C3A6-48B9-A75E-57BB280EBB53,TEST-CONTAINER,test-stamp,test-tenant,TestRuntimeSiteName,TestSlotName",output[1]);
233
+
Assert.Equal($"MS_FUNCTION_LOGS 4,C37E3412-86D1-4B93-BC5A-A2AE09D26C2D,TestApp,TestFunction3,TestEvent,TestSource,\"These are the details, lots of details\",\"This is the summary, a great summary\",{ScriptHost.Version},{timestamp.ToString("O")},TestExceptionType,\"Test exception message, with details\",E2D5A6ED-4CE3-4CFD-8878-FD4814F0A1F3,3AD41658-1C4E-4C9D-B0B9-24F2BDAE2829,F0AAA9AD-C3A6-48B9-A75E-57BB280EBB53,TEST-CONTAINER,test-stamp,test-tenant,TestRuntimeSiteName,TestSlotName",output[2]);
0 commit comments