Skip to content

Commit 793ee53

Browse files
author
mwatson
committed
Add logic to ensure log queue is flushed on shutdown
1 parent 6d08b4b commit 793ee53

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Src/StackifyLib.nLog/StackifyTarget.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@ internal LogMsg Translate(LogEventInfo loggingEvent)
198198
}
199199

200200
}
201-
else
201+
202+
203+
//if it wasn't set above for some reason we will do it this way as a fallback
204+
if (string.IsNullOrEmpty(msg.SrcMethod))
202205
{
203206
msg.SrcMethod = loggingEvent.LoggerName;
204207

Src/StackifyLib/Internal/Logs/LogQueue.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,17 @@ public void Stop()
490490
{
491491
FlushLoop();
492492
}
493+
else
494+
{
495+
DateTime stopWaiting = DateTime.UtcNow.AddSeconds(5);
493496

497+
//wait for it to finish up to 5 seconds
498+
while (_UploadingNow && DateTime.UtcNow < stopWaiting)
499+
{
500+
System.Threading.Thread.Sleep(10);
501+
}
502+
503+
}
494504
Utils.StackifyAPILogger.Log("LogQueue stop complete");
495505
}
496506

0 commit comments

Comments
 (0)