mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-29 08:00:19 +01:00
Adds minimum log level handling to the service
This commit is contained in:
@@ -33,6 +33,18 @@ namespace Tgstation.Server.Host.Service
|
||||
[Option(ShortName = "i")]
|
||||
public bool Install { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The --trace or -t option. Enables trace logs
|
||||
/// </summary>
|
||||
[Option(ShortName = "t")]
|
||||
public bool Trace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The --debug or -d option. Enables debug logs
|
||||
/// </summary>
|
||||
[Option(ShortName = "d")]
|
||||
public bool Debug { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Check if the running user is a system administrator
|
||||
/// </summary>
|
||||
@@ -109,7 +121,7 @@ namespace Tgstation.Server.Host.Service
|
||||
}
|
||||
else
|
||||
using (var loggerFactory = new LoggerFactory())
|
||||
ServiceBase.Run(new ServerService(new WatchdogFactory(), loggerFactory));
|
||||
ServiceBase.Run(new ServerService(new WatchdogFactory(), loggerFactory, Trace ? LogLevel.Trace : Debug ? LogLevel.Debug : LogLevel.Information));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -41,7 +41,8 @@ namespace Tgstation.Server.Host.Service
|
||||
/// </summary>
|
||||
/// <param name="watchdogFactory">The <see cref="IWatchdogFactory"/> to create <see cref="watchdog"/> with</param>
|
||||
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> for <paramref name="watchdogFactory"/></param>
|
||||
public ServerService(IWatchdogFactory watchdogFactory, ILoggerFactory loggerFactory)
|
||||
/// <param name="minumumLogLevel">The minimum <see cref="LogLevel"/> to record in the event log</param>
|
||||
public ServerService(IWatchdogFactory watchdogFactory, ILoggerFactory loggerFactory, LogLevel minumumLogLevel)
|
||||
{
|
||||
if (watchdogFactory == null)
|
||||
throw new ArgumentNullException(nameof(watchdogFactory));
|
||||
@@ -50,7 +51,8 @@ namespace Tgstation.Server.Host.Service
|
||||
|
||||
loggerFactory.AddEventLog(new EventLogSettings
|
||||
{
|
||||
EventLog = this
|
||||
EventLog = this,
|
||||
Filter = (message, logLevel) => logLevel >= minumumLogLevel
|
||||
});
|
||||
|
||||
ServiceName = Name;
|
||||
|
||||
Reference in New Issue
Block a user