tgstation-server 6.12.0
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 public bool ProviderNetworkDebug { get; set; }
36
40 [JsonConverter(typeof(StringEnumConverter))]
41 public LogLevel LogLevel { get; set; } = LogLevel.Debug; // Not a `const` b/c of https://github.com/coverlet-coverage/coverlet/issues/1507
42
46 [JsonConverter(typeof(StringEnumConverter))]
47 public LogLevel MicrosoftLogLevel { get; set; } = LogLevel.Warning; // Not a `const` b/c of https://github.com/coverlet-coverage/coverlet/issues/1507
48
56 public string GetFullLogDirectory(
57 IIOManager ioManager,
58 IAssemblyInformationProvider assemblyInformationProvider,
59 IPlatformIdentifier platformIdentifier)
60 {
61 ArgumentNullException.ThrowIfNull(ioManager);
62 ArgumentNullException.ThrowIfNull(assemblyInformationProvider);
63 ArgumentNullException.ThrowIfNull(platformIdentifier);
64
65 if (!String.IsNullOrEmpty(Directory))
66 return Directory;
67
68 return platformIdentifier.IsWindows
69 ? ioManager.ConcatPath(
70 Environment.GetFolderPath(
71 Environment.SpecialFolder.CommonApplicationData,
72 Environment.SpecialFolderOption.DoNotVerify),
73 assemblyInformationProvider.VersionPrefix,
74 "logs")
75 : ioManager.ConcatPath(
76 "/var/log",
77 assemblyInformationProvider.VersionPrefix);
78 }
79 }
80}
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...
bool ProviderNetworkDebug
If Chat Providers should log their network traffic. Normally disabled because it is too noisy.
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.