-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
255 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "7.0.203" | ||
"version": "7.0.404" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,49 @@ | ||
using System; | ||
using Microsoft.Extensions.Logging; | ||
using Serilog; | ||
using Serilog.Events; | ||
using ILogger = Serilog.ILogger; | ||
|
||
namespace Miru.Foundation.Bootstrap | ||
namespace Miru.Foundation.Bootstrap; | ||
|
||
public class LoggerConfigurations | ||
{ | ||
public class LoggerConfigurations | ||
{ | ||
public static readonly string TimestampOutputTemplate = "{Timestamp:HH:mm:ss.fff} {Message}{NewLine}{Exception}"; | ||
public static readonly string TimestampOutputTemplate = "{Timestamp:HH:mm:ss.fff} {Message}{NewLine}{Exception}"; | ||
|
||
public static readonly string SimpleOutputTemplate = "{Message}{NewLine}{Exception}"; | ||
public static readonly string SimpleOutputTemplate = "{Message}{NewLine}{Exception}"; | ||
|
||
public static readonly string DetailedOutputTemplate = "{Message} - {Level} {SourceContext} {NewLine} {Exception}"; | ||
public static readonly string DetailedOutputTemplate = "{Message} - {Level} {SourceContext} {NewLine} {Exception}"; | ||
|
||
public static readonly ILogger Default = ForCli(); | ||
public static readonly ILogger Default = ForCli(); | ||
|
||
public static readonly LoggerConfiguration DefaultConfiguration = new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
.WriteTo.Console(outputTemplate: SimpleOutputTemplate); | ||
public static readonly LoggerConfiguration DefaultConfiguration = new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
.WriteTo.Console(outputTemplate: SimpleOutputTemplate); | ||
|
||
public static ILogger GetLogger(ArgsConfiguration argsConfig) => argsConfig.IsRunningCli ? ForCli() : ForWeb(); | ||
public static ILogger GetLogger(ArgsConfiguration argsConfig) => | ||
argsConfig.IsRunningCli ? ForCli() : ForWeb(); | ||
|
||
public static ILogger ForCli() => new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
.WriteTo.Console(outputTemplate: SimpleOutputTemplate) | ||
.CreateLogger(); | ||
public static ILogger ForCli() => new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
.WriteTo.Console(outputTemplate: SimpleOutputTemplate) | ||
.CreateLogger(); | ||
|
||
public static ILogger ForWeb() => new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
// .WriteTo.Console(outputTemplate: TimestampOutputTemplate) | ||
.CreateLogger(); | ||
public static ILogger ForWeb() => new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
// .WriteTo.Console(outputTemplate: TimestampOutputTemplate) | ||
.CreateLogger(); | ||
|
||
public static ILoggerFactory CreateLoggerFactory(Action<LoggerConfiguration> config = null) | ||
public static ILoggerFactory CreateLoggerFactory(Action<LoggerConfiguration> config = null) | ||
{ | ||
return LoggerFactory.Create(builder => | ||
{ | ||
return LoggerFactory.Create(builder => | ||
{ | ||
var loggerConfiguration = new LoggerConfiguration() | ||
.MinimumLevel.Warning(); | ||
var loggerConfiguration = new LoggerConfiguration() | ||
.MinimumLevel.Warning(); | ||
config?.Invoke(loggerConfiguration); | ||
config?.Invoke(loggerConfiguration); | ||
loggerConfiguration | ||
.WriteTo.Console(outputTemplate: SimpleOutputTemplate); | ||
loggerConfiguration | ||
.WriteTo.Console(outputTemplate: SimpleOutputTemplate); | ||
builder.AddSerilog(loggerConfiguration.CreateLogger()); | ||
}); | ||
} | ||
builder.AddSerilog(loggerConfiguration.CreateLogger()); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,47 @@ | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using Serilog; | ||
using Serilog.Extensions.Logging; | ||
|
||
namespace Miru.Foundation.Logging | ||
namespace Miru.Foundation.Logging; | ||
|
||
public static class HostBuilderExtensions | ||
{ | ||
public static class HostBuilderExtensions | ||
public static IHostBuilder ConfigureSerilog(this IHostBuilder builder, Action<LoggerConfiguration> config) | ||
{ | ||
public static IHostBuilder ConfigureSerilog(this IHostBuilder builder, Action<LoggerConfiguration> config) | ||
builder.ConfigureServices(services => | ||
{ | ||
builder.ConfigureServices(services => | ||
{ | ||
services.AddSingleton<ILoggerConfigurationBuilder>(new LoggerConfigurationBuilder(config)); | ||
services.AddSingleton<ILoggerConfigurationBuilder>(new LoggerConfigurationBuilder(config)); | ||
services.TryAddSingleton(sp => | ||
{ | ||
var loggerConfiguration = new LoggerConfiguration(); | ||
services.TryAddSingleton(sp => | ||
{ | ||
var loggerConfiguration = new LoggerConfiguration(); | ||
var configBuilders = sp.GetServices<ILoggerConfigurationBuilder>(); | ||
var configBuilders = sp.GetServices<ILoggerConfigurationBuilder>(); | ||
foreach (var configBuilder in configBuilders) | ||
{ | ||
configBuilder.Config(loggerConfiguration); | ||
} | ||
foreach (var configBuilder in configBuilders) | ||
{ | ||
configBuilder.Config(loggerConfiguration); | ||
} | ||
var logger = loggerConfiguration.CreateLogger(); | ||
var logger = loggerConfiguration.CreateLogger(); | ||
return new RegisteredLogger(logger); | ||
}); | ||
return new RegisteredLogger(logger); | ||
}); | ||
services.ReplaceSingleton<ILoggerFactory>(sp => | ||
{ | ||
var logger = sp.GetRequiredService<RegisteredLogger>().Logger; | ||
services.ReplaceSingleton<ILoggerFactory>(sp => | ||
{ | ||
var logger = sp.GetRequiredService<RegisteredLogger>().Logger; | ||
Log.Logger = logger; | ||
Log.Logger = logger; | ||
var factory = new SerilogLoggerFactory(logger, true); | ||
var factory = new SerilogLoggerFactory(logger, true); | ||
return factory; | ||
}); | ||
return factory; | ||
}); | ||
}); | ||
|
||
return builder; | ||
} | ||
return builder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
namespace Miru.Mailing | ||
namespace Miru.Mailing; | ||
|
||
public class SmtpOptions : ServerOptions | ||
{ | ||
public class SmtpOptions | ||
{ | ||
public string Host { get; set; } | ||
public int Port { get; set; } | ||
public string UserName { get; set; } | ||
public string Password { get; set; } | ||
public bool Ssl { get; set; } | ||
} | ||
public bool Ssl { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.