tgstation-server 5.12.7
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
26
31
35 public string Directory { get; set; }
36
40 public bool Disable { get; set; }
41
45 [JsonConverter(typeof(StringEnumConverter))]
46 public LogLevel LogLevel { get; set; } = DefaultLogLevel;
47
51 [JsonConverter(typeof(StringEnumConverter))]
53
61 public string GetFullLogDirectory(
62 IIOManager ioManager,
63 IAssemblyInformationProvider assemblyInformationProvider,
64 IPlatformIdentifier platformIdentifier)
65 {
66 ArgumentNullException.ThrowIfNull(ioManager);
67 ArgumentNullException.ThrowIfNull(assemblyInformationProvider);
68 ArgumentNullException.ThrowIfNull(platformIdentifier);
69
70 var directoryToUse = platformIdentifier.IsWindows
71 ? Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) // C:/ProgramData
72 : "/var/log"; // :pain:
73
74 return !String.IsNullOrEmpty(Directory)
75 ? Directory
76 : ioManager.ConcatPath(
77 directoryToUse,
78 assemblyInformationProvider.VersionPrefix);
79 }
80 }
81}
const LogLevel DefaultMicrosoftLogLevel
Default value for MicrosoftLogLevel.
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.