From 9d55601a277d1b398a31b619fd5b0c90c0b2a306 Mon Sep 17 00:00:00 2001 From: glax Date: Wed, 28 Feb 2024 00:22:55 +0100 Subject: [PATCH] Add fields to get filepaths --- GlaxLogger/GlaxLogger.csproj | 2 +- GlaxLogger/Logger.cs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/GlaxLogger/GlaxLogger.csproj b/GlaxLogger/GlaxLogger.csproj index 57e0b38..099eaae 100644 --- a/GlaxLogger/GlaxLogger.csproj +++ b/GlaxLogger/GlaxLogger.csproj @@ -7,7 +7,7 @@ Glax https://git.bernloehr.eu/glax/GlaxLogger git - 1.0.6 + 1.0.7 diff --git a/GlaxLogger/Logger.cs b/GlaxLogger/Logger.cs index 30aa495..a0f8cb8 100644 --- a/GlaxLogger/Logger.cs +++ b/GlaxLogger/Logger.cs @@ -6,6 +6,7 @@ namespace GlaxLogger; public class Logger : ILogger, IDisposable, IAsyncDisposable { private LogLevel _filterLevel; + public readonly string LogFilePath, FilteredLogFilePath; private readonly FileStream _allMessageLogfile, _filteredLogfile; private readonly ConsoleColor _defaultForegroundColor = Console.ForegroundColor; private readonly ConsoleColor _defaultBackgroundColor = Console.BackgroundColor; @@ -16,8 +17,10 @@ public class Logger : ILogger, IDisposable, IAsyncDisposable this._filterLevel = filteredLevel; string logFolderPath = outputFolderPath ?? Path.Join(Environment.CurrentDirectory, "logs"); Directory.CreateDirectory(logFolderPath); - this._filteredLogfile = new FileStream(Path.Join(logFolderPath, $"{DateTime.Now:yyyy-MM-dd HH.mm.ss}-filtered.log"), FileMode.Create); - this._allMessageLogfile = new FileStream(Path.Join(logFolderPath, $"{DateTime.Now:yyyy-MM-dd HH.mm.ss}.log"), FileMode.Create); + this.LogFilePath = Path.Join(logFolderPath, $"{DateTime.Now:yyyy-MM-dd HH.mm.ss}.log"); + this.FilteredLogFilePath = Path.Join(logFolderPath, $"{DateTime.Now:yyyy-MM-dd HH.mm.ss}-filtered.log"); + this._allMessageLogfile = new FileStream(this.LogFilePath, FileMode.Create); + this._filteredLogfile = new FileStream(this.FilteredLogFilePath, FileMode.Create); this._consoleOut = consoleOut ?? Console.Out; }