Skip to content

Commit 9f55f5f

Browse files
committed
gh-65 Use .NET 6.0 high performance structured logging
Signed-off-by: Victor Chang <[email protected]>
1 parent 8cb2f26 commit 9f55f5f

File tree

67 files changed

+1307
-445829
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1307
-445829
lines changed

src/Api/Storage/DicomFileStorageInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected override string GenerateStoragePath()
6363
Guard.Against.NullOrWhiteSpace(SeriesInstanceUid, nameof(SeriesInstanceUid));
6464
Guard.Against.NullOrWhiteSpace(SopInstanceUid, nameof(SopInstanceUid));
6565

66-
string filePath = System.IO.Path.Combine(StorageRootPath, StudyInstanceUid, SeriesInstanceUid, SopInstanceUid) + FileExtension;
66+
var filePath = System.IO.Path.Combine(StorageRootPath, StudyInstanceUid, SeriesInstanceUid, SopInstanceUid) + FileExtension;
6767
filePath = filePath.ToLowerInvariant();
6868
var index = 1;
6969
while (FileSystem.File.Exists(filePath))

src/Api/Storage/FhirFileStorageInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected override string GenerateStoragePath()
4242
Guard.Against.NullOrWhiteSpace(ResourceType, nameof(ResourceType));
4343
Guard.Against.NullOrWhiteSpace(MessageId, nameof(MessageId));
4444

45-
string filePath = System.IO.Path.Combine(StorageRootPath, DirectoryPath, ResourceType, MessageId) + FileExtension;
45+
var filePath = System.IO.Path.Combine(StorageRootPath, DirectoryPath, ResourceType, MessageId) + FileExtension;
4646
filePath = filePath.ToLowerInvariant();
4747
var index = 1;
4848
while (FileSystem.File.Exists(filePath))

src/Api/Storage/Payload.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Diagnostics;
77
using Ardalis.GuardClauses;
88
using Monai.Deploy.InformaticsGateway.Common;
9+
910
namespace Monai.Deploy.InformaticsGateway.Api.Storage
1011
{
1112
public class Payload : IDisposable
@@ -86,7 +87,6 @@ public void Add(FileStorageInfo value)
8687
{
8788
foreach (var workflow in value.Workflows)
8889
{
89-
9090
Workflows.Add(workflow);
9191
}
9292
}

src/CLI/Commands/ConfigCommand.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using Ardalis.GuardClauses;
1010
using Microsoft.Extensions.DependencyInjection;
1111
using Microsoft.Extensions.Hosting;
12-
using Microsoft.Extensions.Logging;
1312
using Monai.Deploy.InformaticsGateway.CLI.Services;
1413

1514
namespace Monai.Deploy.InformaticsGateway.CLI
@@ -114,7 +113,7 @@ private static int ConfigUpdateHandler(IHost host, Action<IConfigurationService>
114113
{
115114
CheckConfiguration(config);
116115
updater(config);
117-
logger.Log(LogLevel.Information, "Configuration updated successfully.");
116+
logger.ConfigurationUpdated();
118117
}
119118
catch (ConfigurationException ex)
120119
{
@@ -141,7 +140,7 @@ private async Task<int> InitHandlerAsync(IHost host, bool verbose, bool yes, Can
141140

142141
if (!yes && configService.IsConfigExists && !confirmation.ShowConfirmationPrompt($"Existing application configuration file already exists. Do you want to overwrite it?"))
143142
{
144-
logger.Log(LogLevel.Warning, "Action cancelled.");
143+
logger.ActionCancelled();
145144
return ExitCodes.Stop_Cancelled;
146145
}
147146

src/CLI/Commands/RestartCommand.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Ardalis.GuardClauses;
99
using Microsoft.Extensions.DependencyInjection;
1010
using Microsoft.Extensions.Hosting;
11-
using Microsoft.Extensions.Logging;
1211
using Monai.Deploy.InformaticsGateway.CLI.Services;
1312

1413
namespace Monai.Deploy.InformaticsGateway.CLI
@@ -35,7 +34,7 @@ private async Task<int> RestartCommandHandler(IHost host, bool yes, bool verbose
3534

3635
if (!yes && !confirmation.ShowConfirmationPrompt($"Do you want to restart {Strings.ApplicationName}?"))
3736
{
38-
logger.Log(LogLevel.Warning, "Action cancelled.");
37+
logger.ActionCancelled();
3938
return ExitCodes.Restart_Cancelled;
4039
}
4140

@@ -45,7 +44,7 @@ private async Task<int> RestartCommandHandler(IHost host, bool yes, bool verbose
4544
}
4645
catch (Exception ex)
4746
{
48-
logger.Log(LogLevel.Critical, $"Error restarting {Strings.ApplicationName}: {ex.Message}");
47+
logger.ErrorRestarting(Strings.ApplicationName, ex.Message);
4948
return ExitCodes.Restart_Error;
5049
}
5150
return ExitCodes.Success;

src/CLI/Commands/StartCommand.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Ardalis.GuardClauses;
99
using Microsoft.Extensions.DependencyInjection;
1010
using Microsoft.Extensions.Hosting;
11-
using Microsoft.Extensions.Logging;
1211
using Monai.Deploy.InformaticsGateway.CLI.Services;
1312

1413
namespace Monai.Deploy.InformaticsGateway.CLI
@@ -39,12 +38,12 @@ private async Task<int> StartCommandHandler(IHost host, bool verbose, Cancellati
3938
}
4039
catch (ControlException ex) when (ex.ErrorCode == ExitCodes.Start_Error_ApplicationAlreadyRunning)
4140
{
42-
logger.Log(LogLevel.Warning, ex.Message);
41+
logger.WarningMessage(ex.Message);
4342
return ex.ErrorCode;
4443
}
4544
catch (Exception ex)
4645
{
47-
logger.Log(LogLevel.Critical, ex.Message);
46+
logger.CriticalException(ex.Message);
4847
return ExitCodes.Start_Error;
4948
}
5049
return ExitCodes.Success;

src/CLI/Commands/StopCommand.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Ardalis.GuardClauses;
99
using Microsoft.Extensions.DependencyInjection;
1010
using Microsoft.Extensions.Hosting;
11-
using Microsoft.Extensions.Logging;
1211
using Monai.Deploy.InformaticsGateway.CLI.Services;
1312

1413
namespace Monai.Deploy.InformaticsGateway.CLI
@@ -35,7 +34,7 @@ private async Task<int> StopCommandHandler(IHost host, bool yes, bool verbose, C
3534

3635
if (!yes && !confirmation.ShowConfirmationPrompt($"Do you want to stop {Strings.ApplicationName}?"))
3736
{
38-
logger.Log(LogLevel.Warning, "Action cancelled.");
37+
logger.ActionCancelled();
3938
return ExitCodes.Stop_Cancelled;
4039
}
4140

@@ -45,7 +44,7 @@ private async Task<int> StopCommandHandler(IHost host, bool yes, bool verbose, C
4544
}
4645
catch (Exception ex)
4746
{
48-
logger.Log(LogLevel.Critical, ex, ex.Message);
47+
logger.CriticalException(ex.Message);
4948
return ExitCodes.Stop_Error;
5049
}
5150
return ExitCodes.Success;

src/CLI/ControlException.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ protected ControlException(SerializationInfo info, StreamingContext context) : b
3333
{
3434
ErrorCode = info.GetInt32(nameof(ErrorCode));
3535
}
36+
3637
public override void GetObjectData(SerializationInfo info, StreamingContext context)
3738
{
3839
Guard.Against.Null(info, nameof(info));

src/CLI/Logging/ConsoleLoggerProvider.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ protected virtual void Dispose(bool disposing)
2929
if (disposing)
3030
{
3131
_loggers.Clear();
32-
3332
}
3433

3534
_disposedValue = true;

0 commit comments

Comments
 (0)