Skip to content

Commit

Permalink
chore: update logger
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Nov 8, 2022
1 parent 870583d commit ac34394
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions GZCTF/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
builder.Configuration.AddEnvironmentVariables("GZCTF_");
Log.Logger = LogHelper.GetInitLogger();

Log.Logger.Debug("GZCTF 正在启动中……");

#endregion Logging

#region AppDbContext
Expand Down
3 changes: 2 additions & 1 deletion GZCTF/Utils/LogHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public static void Log<T>(this ILogger<T> _logger, string msg, string uname, str
};

private const string LogTemplate = "[{@t:yy-MM-dd HH:mm:ss.fff} {@l:u3}] {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1)}: {@m} {#if Length(Status) > 0}#{Status} <{UserName}>{#if Length(IP) > 0}@{IP}{#end}{#end}\n{@x}";
private const string InitLogTemplate = "[{@t:yy-MM-dd HH:mm:ss.fff} {@l:u3}] {@m}\n{@x}";

public static Logger GetInitLogger()
=> new LoggerConfiguration()
Expand All @@ -103,7 +104,7 @@ public static Logger GetInitLogger()
.MinimumLevel.Override("Microsoft.Hosting.Lifetime", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.Hosting.Lifetime", LogEventLevel.Warning)
.WriteTo.Async(t => t.Console(
formatter: new ExpressionTemplate(LogTemplate, theme: TemplateTheme.Literate),
formatter: new ExpressionTemplate(InitLogTemplate, theme: TemplateTheme.Literate),
restrictedToMinimumLevel: LogEventLevel.Debug
))
.CreateLogger();
Expand Down

0 comments on commit ac34394

Please sign in to comment.