mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-16 11:42:22 +08:00
parent
03ca7be644
commit
c12d2c1cb0
|
@ -384,7 +384,13 @@ namespace BililiveRecorder.Cli
|
||||||
.AddRecorder()
|
.AddRecorder()
|
||||||
.BuildServiceProvider();
|
.BuildServiceProvider();
|
||||||
|
|
||||||
private static Logger BuildLogger(LogEventLevel logLevel, LogEventLevel logFileLevel) => new LoggerConfiguration()
|
private static Logger BuildLogger(LogEventLevel logLevel, LogEventLevel logFileLevel)
|
||||||
|
{
|
||||||
|
var logFilePath = Environment.GetEnvironmentVariable("BILILIVERECORDER_LOG_FILE_PATH");
|
||||||
|
if (string.IsNullOrWhiteSpace(logFilePath))
|
||||||
|
logFilePath = Path.Combine(AppContext.BaseDirectory, "logs", "bilirec.txt");
|
||||||
|
|
||||||
|
return new LoggerConfiguration()
|
||||||
.MinimumLevel.Verbose()
|
.MinimumLevel.Verbose()
|
||||||
.Enrich.WithProcessId()
|
.Enrich.WithProcessId()
|
||||||
.Enrich.WithThreadId()
|
.Enrich.WithThreadId()
|
||||||
|
@ -401,8 +407,9 @@ namespace BililiveRecorder.Cli
|
||||||
x.FileModificationTime,
|
x.FileModificationTime,
|
||||||
})
|
})
|
||||||
.WriteTo.Console(restrictedToMinimumLevel: logLevel, outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] [{RoomId}] {Message:lj}{NewLine}{Exception}")
|
.WriteTo.Console(restrictedToMinimumLevel: logLevel, outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] [{RoomId}] {Message:lj}{NewLine}{Exception}")
|
||||||
.WriteTo.File(new CompactJsonFormatter(), "./logs/bilirec.txt", restrictedToMinimumLevel: logFileLevel, shared: true, rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true)
|
.WriteTo.File(new CompactJsonFormatter(), logFilePath, restrictedToMinimumLevel: logFileLevel, shared: true, rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true)
|
||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
|
}
|
||||||
|
|
||||||
public abstract class SharedArguments
|
public abstract class SharedArguments
|
||||||
{
|
{
|
||||||
|
|
|
@ -211,7 +211,13 @@ namespace BililiveRecorder.WPF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Logger BuildLogger() => new LoggerConfiguration()
|
private static Logger BuildLogger()
|
||||||
|
{
|
||||||
|
var logFilePath = Environment.GetEnvironmentVariable("BILILIVERECORDER_LOG_FILE_PATH");
|
||||||
|
if (string.IsNullOrWhiteSpace(logFilePath))
|
||||||
|
logFilePath = Path.Combine(AppContext.BaseDirectory, "logs", "bilirec.txt");
|
||||||
|
|
||||||
|
return new LoggerConfiguration()
|
||||||
.MinimumLevel.ControlledBy(levelSwitchGlobal)
|
.MinimumLevel.ControlledBy(levelSwitchGlobal)
|
||||||
.Enrich.WithProcessId()
|
.Enrich.WithProcessId()
|
||||||
.Enrich.WithThreadId()
|
.Enrich.WithThreadId()
|
||||||
|
@ -234,7 +240,7 @@ namespace BililiveRecorder.WPF
|
||||||
#else
|
#else
|
||||||
.WriteTo.Sink<WpfLogEventSink>(Serilog.Events.LogEventLevel.Information)
|
.WriteTo.Sink<WpfLogEventSink>(Serilog.Events.LogEventLevel.Information)
|
||||||
#endif
|
#endif
|
||||||
.WriteTo.File(new CompactJsonFormatter(), "./logs/bilirec.txt", shared: true, rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true)
|
.WriteTo.File(new CompactJsonFormatter(), logFilePath, shared: true, rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true)
|
||||||
.WriteTo.Sentry(o =>
|
.WriteTo.Sentry(o =>
|
||||||
{
|
{
|
||||||
o.Dsn = "https://38036b2031474b8ba0a728ac2a961cfa@o210546.ingest.sentry.io/5556540";
|
o.Dsn = "https://38036b2031474b8ba0a728ac2a961cfa@o210546.ingest.sentry.io/5556540";
|
||||||
|
@ -261,6 +267,8 @@ namespace BililiveRecorder.WPF
|
||||||
})
|
})
|
||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport("kernel32")]
|
[DllImport("kernel32")]
|
||||||
private static extern bool AttachConsole(int pid);
|
private static extern bool AttachConsole(int pid);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user