This commit is contained in:
2024-05-27 20:11:11 +02:00
parent c997b6c1a2
commit 005d91c199
19 changed files with 717 additions and 435 deletions

View File

@@ -21,7 +21,7 @@ public class LoggerSettings
private FileLoggerOptions _fileLoggerOptions;
private string _headerFormat = "{ts} {host} {thread} {sev}";
private string _headerFormat = "{ts} {host} {category} {thread} {sev}";
private int _maxMessageLength = 1024;
private string _timestampFormat = "yyyy-MM-dd HH:mm:ss";
@@ -43,9 +43,10 @@ public class LoggerSettings
/// variables including:
/// {ts}: UTC timestamp
/// {host}: Hostname
/// {category}: Category
/// {thread}: Thread ID
/// {sev}: Severity
/// Default: {ts} {host} {thread} {sev}
/// Default: {ts} {host} {category} {thread} {sev}
/// A space will be inserted between the header and the message.
/// </summary>
public string HeaderFormat
@@ -53,8 +54,14 @@ public class LoggerSettings
get => _headerFormat;
set
{
if (string.IsNullOrEmpty(value)) _headerFormat = "";
else _headerFormat = value;
if (string.IsNullOrEmpty(value))
{
_headerFormat = "";
}
else
{
_headerFormat = value;
}
}
}
@@ -66,7 +73,11 @@ public class LoggerSettings
get => _timestampFormat;
set
{
if (string.IsNullOrEmpty(value)) throw new ArgumentNullException(nameof(HeaderFormat));
if (string.IsNullOrEmpty(value))
{
throw new ArgumentNullException(nameof(HeaderFormat));
}
_timestampFormat = value;
}
}
@@ -81,8 +92,14 @@ public class LoggerSettings
get => _enableConsole;
set
{
if (value) _enableConsole = ConsoleExists();
else _enableConsole = false;
if (value)
{
_enableConsole = ConsoleExists();
}
else
{
_enableConsole = false;
}
}
}
@@ -99,7 +116,11 @@ public class LoggerSettings
get => _colors;
set
{
if (value == null) throw new ArgumentNullException(nameof(Colors));
if (value == null)
{
throw new ArgumentNullException(nameof(Colors));
}
_colors = value;
}
}
@@ -130,7 +151,11 @@ public class LoggerSettings
{
get
{
if (_fileLoggerOptions == null) _fileLoggerOptions = CreateDefaultFileLoggerOptions();
if (_fileLoggerOptions == null)
{
_fileLoggerOptions = CreateDefaultFileLoggerOptions();
}
return _fileLoggerOptions;
}