|
@@ -8,6 +8,7 @@ using System;
|
|
|
using TEAMModelOS.SDK.DI;
|
|
|
using Azure;
|
|
|
using Azure.Storage.Blobs.Specialized;
|
|
|
+using System.Threading.Tasks;
|
|
|
|
|
|
namespace TEAMModelOS.Filter
|
|
|
{
|
|
@@ -54,27 +55,25 @@ namespace TEAMModelOS.Filter
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
|
|
+ public async void Log<TState> ( LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
|
|
{
|
|
|
if (formatter == null)
|
|
|
{
|
|
|
throw new ArgumentNullException(nameof(formatter));
|
|
|
}
|
|
|
-
|
|
|
var message = formatter(state, exception);
|
|
|
var appendBlob = _containerClient.GetAppendBlobClient($"{_categoryName}/{DateTimeOffset.UtcNow:yyyy-MM-dd}.log");
|
|
|
// var blobClient = _containerClient.GetBlobClient($"{_categoryName}/{DateTimeOffset.UtcNow:yyyy-MM-dd}.log");
|
|
|
if (!appendBlob.Exists())
|
|
|
{
|
|
|
- appendBlob.Create();
|
|
|
+ await appendBlob.CreateAsync();
|
|
|
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(message));
|
|
|
- appendBlob.AppendBlock(stream);
|
|
|
+ await appendBlob.AppendBlockAsync(stream);
|
|
|
}
|
|
|
else {
|
|
|
using var stream = new MemoryStream(Encoding.UTF8.GetBytes($"\n,{message}"));
|
|
|
- appendBlob.AppendBlock(stream);
|
|
|
+ await appendBlob.AppendBlockAsync(stream);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|