Hermod
A cross-platform, modular and fully GDPR-compliant email archival solution!
Loading...
Searching...
No Matches
LoggerConfig.cs
Go to the documentation of this file.
1using System;
2
4
5 using Core;
6
7 using Serilog.Events;
8
12 public class LoggerConfig {
13
14 public LoggerConfig() { }
15
16 public bool EnableLogging { get; set; }
17
18 public string? LogLevel { get; set; }
19
21 get {
22 switch (LogLevel?.ToLowerInvariant()) {
23 default:
24 case "warn":
25 case "warning":
26 return LogEventLevel.Warning;
27 case "trace":
28 case "debug":
29 return LogEventLevel.Debug;
30 case "info":
31 case "information":
32 case "informational":
33 return LogEventLevel.Information;
34 case "error":
35 return LogEventLevel.Error;
36 case "critical":
37 case "fatal":
38 return LogEventLevel.Fatal;
39 }
40 }
41 }
42
43 private string? m_logLocation;
44 public string? LogLocation {
45 get => m_logLocation;
46 set {
47 var tmp = value?.ToLowerInvariant() ?? "sysdefault"; // allow silent failure
48
49 switch (tmp) {
50 case "sysdefault":
51 tmp = Path.Combine(AppInfo.GetLocalHermodDirectory().FullName, AppInfo.HermodLogDirName);
52 return;
53 case "hermoddir":
54 tmp = Path.Combine(AppInfo.GetBaseHermodDirectory().FullName, AppInfo.HermodLogDirName);
55 break;
56 default:
57 break;
58 }
59
60 m_logLocation = tmp;
61 }
62 }
63
64 public string? LogFileName { get; set; }
65 }
66}
67
Contains configuration information specific to logger configurations.
Definition: LoggerConfig.cs:12
Static class containing basic information for and about the application.
Definition: AppInfo.cs:10
static DirectoryInfo GetLocalHermodDirectory()
Gets the application's local data directory.
Definition: AppInfo.cs:59
static DirectoryInfo GetBaseHermodDirectory()
Gets the application's base data directory.
Definition: AppInfo.cs:37
static string HermodLogDirName
Gets the name of the application's log directory. Typically this is stored.
Definition: AppInfo.cs:31