tgstation-server 6.6.1
The /tg/station 13 server suite
Loading...
Searching...
No Matches
FileLoggingConfiguration.cs
Go to the documentation of this file.
1using System;
2
3using Microsoft.Extensions.Logging;
4using Newtonsoft.Json;
5using Newtonsoft.Json.Converters;
6
9
11{
15 public sealed class FileLoggingConfiguration
16 {
20 public const string Section = "FileLogging";
21
25 public string? Directory { get; set; }
26
30 public bool Disable { get; set; }
31
35 [JsonConverter(typeof(StringEnumConverter))]
36 public LogLevel LogLevel { get; set; } = LogLevel.Debug; // Not a `const` b/c of https://github.com/coverlet-coverage/coverlet/issues/1507
37
41 [JsonConverter(typeof(StringEnumConverter))]
42 public LogLevel MicrosoftLogLevel { get; set; } = LogLevel.Warning; // Not a `const` b/c of https://github.com/coverlet-coverage/coverlet/issues/1507
43
51 public string GetFullLogDirectory(
52 IIOManager ioManager,
53 IAssemblyInformationProvider assemblyInformationProvider,
54 IPlatformIdentifier platformIdentifier)
55 {
56 ArgumentNullException.ThrowIfNull(ioManager);
57 ArgumentNullException.ThrowIfNull(assemblyInformationProvider);
58 ArgumentNullException.ThrowIfNull(platformIdentifier);
59
60 if (!String.IsNullOrEmpty(Directory))
61 return Directory;
62
63 return platformIdentifier.IsWindows
64 ? ioManager.ConcatPath(
65 Environment.GetFolderPath(
66 Environment.SpecialFolder.CommonApplicationData,
67 Environment.SpecialFolderOption.DoNotVerify),
68 assemblyInformationProvider.VersionPrefix,
69 "logs")
70 : ioManager.ConcatPath(
71 "/var/log",
72 assemblyInformationProvider.VersionPrefix);
73 }
74 }
75}
LogLevel MicrosoftLogLevel
The minimum Microsoft.Extensions.Logging.LogLevel to display in logs for Microsoft library sources.
string GetFullLogDirectory(IIOManager ioManager, IAssemblyInformationProvider assemblyInformationProvider, IPlatformIdentifier platformIdentifier)
Gets the evaluated log Directory.
LogLevel LogLevel
The minimum Microsoft.Extensions.Logging.LogLevel to display in logs.
const string Section
The key for the Microsoft.Extensions.Configuration.IConfigurationSection the FileLoggingConfiguration...
Interface for using filesystems.
Definition: IIOManager.cs:13
string ConcatPath(params string[] paths)
Combines an array of strings into a path.
For identifying the current platform.