|
|
|
@ -1,5 +1,5 @@ |
|
|
|
// ==========================================================================
|
|
|
|
// FileLogChannel.cs
|
|
|
|
// FileLogProcessor.cs
|
|
|
|
// Squidex Headless CMS
|
|
|
|
// ==========================================================================
|
|
|
|
// Copyright (c) Squidex Group
|
|
|
|
@ -12,9 +12,11 @@ using System.IO; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
// ReSharper disable InvertIf
|
|
|
|
|
|
|
|
namespace Squidex.Infrastructure.Log.Internal |
|
|
|
{ |
|
|
|
public class FileLogProcessor : IDisposable |
|
|
|
public class FileLogProcessor : DisposableObjectBase |
|
|
|
{ |
|
|
|
private const int MaxQueuedMessages = 1024; |
|
|
|
private const int Retries = 10; |
|
|
|
@ -29,6 +31,25 @@ namespace Squidex.Infrastructure.Log.Internal |
|
|
|
outputTask = Task.Factory.StartNew(ProcessLogQueue, this, TaskCreationOptions.LongRunning); |
|
|
|
} |
|
|
|
|
|
|
|
protected override void DisposeObject(bool disposing) |
|
|
|
{ |
|
|
|
if (disposing) |
|
|
|
{ |
|
|
|
messageQueue.CompleteAdding(); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
outputTask.Wait(1500); |
|
|
|
} |
|
|
|
catch (TaskCanceledException) |
|
|
|
{ |
|
|
|
} |
|
|
|
catch (AggregateException ex) when (ex.InnerExceptions.Count == 1 && ex.InnerExceptions[0] is TaskCanceledException) |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void Connect() |
|
|
|
{ |
|
|
|
var fileInfo = new FileInfo(path); |
|
|
|
@ -75,21 +96,5 @@ namespace Squidex.Infrastructure.Log.Internal |
|
|
|
|
|
|
|
return processor.ProcessLogQueue(); |
|
|
|
} |
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
{ |
|
|
|
messageQueue.CompleteAdding(); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
outputTask.Wait(1500); |
|
|
|
} |
|
|
|
catch (TaskCanceledException) |
|
|
|
{ |
|
|
|
} |
|
|
|
catch (AggregateException ex) when (ex.InnerExceptions.Count == 1 && ex.InnerExceptions[0] is TaskCanceledException) |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |