mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 22:07:28 +02:00
Version 3.0.338
This commit is contained in:
parent
573fe77e12
commit
0468955d49
751 changed files with 62747 additions and 60672 deletions
|
@ -2,19 +2,19 @@
|
|||
|
||||
namespace TINK.Model.Logging
|
||||
{
|
||||
public class EmptyDirectoryLoggingManger : ILoggingDirectoryManager
|
||||
{
|
||||
public void DeleteObsoleteLogs() { }
|
||||
public class EmptyDirectoryLoggingManger : ILoggingDirectoryManager
|
||||
{
|
||||
public void DeleteObsoleteLogs() { }
|
||||
|
||||
/// <summary> Gets the log file name. </summary>
|
||||
public string LogFileName { get { return string.Empty; } }
|
||||
/// <summary> Gets the log file name. </summary>
|
||||
public string LogFileName { get { return string.Empty; } }
|
||||
|
||||
/// <summary> Gets all log files in logging directory. </summary>
|
||||
/// <returns>List of log files.</returns>
|
||||
public IList<string> GetLogFiles() { return new List<string>(); }
|
||||
/// <summary> Gets all log files in logging directory. </summary>
|
||||
/// <returns>List of log files.</returns>
|
||||
public IList<string> GetLogFiles() { return new List<string>(); }
|
||||
|
||||
/// <summary> Gets path where log files are located. </summary>
|
||||
/// <returns>Path to log files.</returns>
|
||||
public string LogFilePath { get { return string.Empty; } }
|
||||
}
|
||||
/// <summary> Gets path where log files are located. </summary>
|
||||
/// <returns>Path to log files.</returns>
|
||||
public string LogFilePath { get { return string.Empty; } }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
|
||||
namespace TINK.Model.Logging
|
||||
{
|
||||
public interface ILoggingDirectoryManager
|
||||
{
|
||||
/// <summary> Deletes files which are out of retainment scope. </summary>
|
||||
void DeleteObsoleteLogs();
|
||||
public interface ILoggingDirectoryManager
|
||||
{
|
||||
/// <summary> Deletes files which are out of retainment scope. </summary>
|
||||
void DeleteObsoleteLogs();
|
||||
|
||||
/// <summary> Gets the log file name. </summary>
|
||||
string LogFileName { get; }
|
||||
/// <summary> Gets the log file name. </summary>
|
||||
string LogFileName { get; }
|
||||
|
||||
/// <summary> Gets all log files in logging directory. </summary>
|
||||
/// <returns>List of log files.</returns>
|
||||
IList<string> GetLogFiles();
|
||||
/// <summary> Gets all log files in logging directory. </summary>
|
||||
/// <returns>List of log files.</returns>
|
||||
IList<string> GetLogFiles();
|
||||
|
||||
/// <summary> Gets path where log files are located. </summary>
|
||||
/// <returns>Path to log files.</returns>
|
||||
string LogFilePath { get; }
|
||||
}
|
||||
/// <summary> Gets path where log files are located. </summary>
|
||||
/// <returns>Path to log files.</returns>
|
||||
string LogFilePath { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,32 +4,32 @@ using TINK.Repository.Exception;
|
|||
|
||||
namespace TINK.Model.Logging
|
||||
{
|
||||
public static class LogEntryClassifyHelper
|
||||
{
|
||||
/// <summary> Classifies exception and logs information or error depending on result of classification. </summary>
|
||||
/// <typeparam name="T0">Type of first message parameter.</typeparam>
|
||||
/// <typeparam name="T1">Type of second message parameter.</typeparam>
|
||||
/// <param name="p_oLogger">Object to use for logging.</param>
|
||||
/// <param name="messageTemplate">Templated used to output message.</param>
|
||||
/// <param name="propertyValue0">First message parameter.</param>
|
||||
/// <param name="propertyValue1">Second message parameter.</param>
|
||||
/// <param name="p_oException">Exception to classify.</param>
|
||||
public static void InformationOrError<T0, T1>(this ILogger p_oLogger, string messageTemplate, T0 propertyValue0, T1 propertyValue1, Exception p_oException)
|
||||
{
|
||||
if (p_oException == null)
|
||||
{
|
||||
p_oLogger.Error(messageTemplate, propertyValue0, propertyValue1, string.Empty);
|
||||
return;
|
||||
}
|
||||
public static class LogEntryClassifyHelper
|
||||
{
|
||||
/// <summary> Classifies exception and logs information or error depending on result of classification. </summary>
|
||||
/// <typeparam name="T0">Type of first message parameter.</typeparam>
|
||||
/// <typeparam name="T1">Type of second message parameter.</typeparam>
|
||||
/// <param name="p_oLogger">Object to use for logging.</param>
|
||||
/// <param name="messageTemplate">Templated used to output message.</param>
|
||||
/// <param name="propertyValue0">First message parameter.</param>
|
||||
/// <param name="propertyValue1">Second message parameter.</param>
|
||||
/// <param name="p_oException">Exception to classify.</param>
|
||||
public static void InformationOrError<T0, T1>(this ILogger p_oLogger, string messageTemplate, T0 propertyValue0, T1 propertyValue1, Exception p_oException)
|
||||
{
|
||||
if (p_oException == null)
|
||||
{
|
||||
p_oLogger.Error(messageTemplate, propertyValue0, propertyValue1, string.Empty);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_oException.GetIsConnectFailureException())
|
||||
{
|
||||
// Expected exception (LAN or mobile data off/ not reachable, proxy, ...)
|
||||
p_oLogger.Information(messageTemplate, propertyValue0, propertyValue1, p_oException);
|
||||
return;
|
||||
}
|
||||
if (p_oException.GetIsConnectFailureException())
|
||||
{
|
||||
// Expected exception (LAN or mobile data off/ not reachable, proxy, ...)
|
||||
p_oLogger.Information(messageTemplate, propertyValue0, propertyValue1, p_oException);
|
||||
return;
|
||||
}
|
||||
|
||||
p_oLogger.Error(messageTemplate, propertyValue0, propertyValue1, p_oException);
|
||||
}
|
||||
}
|
||||
p_oLogger.Error(messageTemplate, propertyValue0, propertyValue1, p_oException);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,104 +7,104 @@ using Serilog.Formatting.Json;
|
|||
|
||||
namespace TINK.Model.Logging
|
||||
{
|
||||
/// <summary> Holds new logging levels. </summary>
|
||||
public enum RollingInterval
|
||||
{
|
||||
/// <summary> Create a new log file for each session (start of app).</summary>
|
||||
Session,
|
||||
}
|
||||
/// <summary> Holds new logging levels. </summary>
|
||||
public enum RollingInterval
|
||||
{
|
||||
/// <summary> Create a new log file for each session (start of app).</summary>
|
||||
Session,
|
||||
}
|
||||
|
||||
/// <summary> Provides logging file name helper functionality.</summary>
|
||||
public static class LoggerConfigurationHelper
|
||||
{
|
||||
// Max count of retained logs count.
|
||||
private const int RETAINEDFILECOUNT = 10;
|
||||
/// <summary> Provides logging file name helper functionality.</summary>
|
||||
public static class LoggerConfigurationHelper
|
||||
{
|
||||
// Max count of retained logs count.
|
||||
private const int RETAINEDFILECOUNT = 10;
|
||||
|
||||
// Max size of logging file.
|
||||
private const int MAXLOGFILESSIZEBYTESBYTES = 1024 * 1024 * 8; // 8MB
|
||||
// Max size of logging file.
|
||||
private const int MAXLOGFILESSIZEBYTESBYTES = 1024 * 1024 * 8; // 8MB
|
||||
|
||||
/// <summary> Holds the log file name. </summary>
|
||||
private static ILoggingDirectoryManager DirectoryManager { get; set; } = new EmptyDirectoryLoggingManger();
|
||||
/// <summary> Holds the log file name. </summary>
|
||||
private static ILoggingDirectoryManager DirectoryManager { get; set; } = new EmptyDirectoryLoggingManger();
|
||||
|
||||
/// <summary> Sets up logging to file.</summary>
|
||||
/// <param name="loggerConfiguration">Object to set up logging with.</param>
|
||||
/// <param name="p_oDevice">Object to get file informaton from.</param>
|
||||
/// <param name="rollingInterval">Specifies rolling type.</param>
|
||||
/// <param name="retainedFilesCountLimit">Count of file being retained.</param>
|
||||
/// <returns>Logger object.</returns>
|
||||
public static LoggerConfiguration File(
|
||||
this LoggerSinkConfiguration loggerConfiguration,
|
||||
string logFileFolder,
|
||||
RollingInterval rollingInterval = RollingInterval.Session,
|
||||
int retainedFilesCountLimit = RETAINEDFILECOUNT)
|
||||
{
|
||||
if (DirectoryManager is EmptyDirectoryLoggingManger)
|
||||
{
|
||||
// Roll file only once per app session.
|
||||
try
|
||||
{
|
||||
DirectoryManager = new LoggingDirectoryManager(
|
||||
Directory.GetFiles,
|
||||
Directory.Exists,
|
||||
(path) => Directory.CreateDirectory(path),
|
||||
System.IO.File.Delete,
|
||||
logFileFolder,
|
||||
Path.DirectorySeparatorChar,
|
||||
retainedFilesCountLimit);
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
Log.Error("Log directory manager could not be instanciated successfully. {@l_oException}", l_oException);
|
||||
DirectoryManager = new EmptyDirectoryLoggingManger();
|
||||
}
|
||||
}
|
||||
/// <summary> Sets up logging to file.</summary>
|
||||
/// <param name="loggerConfiguration">Object to set up logging with.</param>
|
||||
/// <param name="p_oDevice">Object to get file informaton from.</param>
|
||||
/// <param name="rollingInterval">Specifies rolling type.</param>
|
||||
/// <param name="retainedFilesCountLimit">Count of file being retained.</param>
|
||||
/// <returns>Logger object.</returns>
|
||||
public static LoggerConfiguration File(
|
||||
this LoggerSinkConfiguration loggerConfiguration,
|
||||
string logFileFolder,
|
||||
RollingInterval rollingInterval = RollingInterval.Session,
|
||||
int retainedFilesCountLimit = RETAINEDFILECOUNT)
|
||||
{
|
||||
if (DirectoryManager is EmptyDirectoryLoggingManger)
|
||||
{
|
||||
// Roll file only once per app session.
|
||||
try
|
||||
{
|
||||
DirectoryManager = new LoggingDirectoryManager(
|
||||
Directory.GetFiles,
|
||||
Directory.Exists,
|
||||
(path) => Directory.CreateDirectory(path),
|
||||
System.IO.File.Delete,
|
||||
logFileFolder,
|
||||
Path.DirectorySeparatorChar,
|
||||
retainedFilesCountLimit);
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
Log.Error("Log directory manager could not be instanciated successfully. {@l_oException}", l_oException);
|
||||
DirectoryManager = new EmptyDirectoryLoggingManger();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
DirectoryManager.DeleteObsoleteLogs();
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
Log.Error("Not all obsolte log files could be deleted successfully. {@l_oException}", l_oException);
|
||||
}
|
||||
try
|
||||
{
|
||||
DirectoryManager.DeleteObsoleteLogs();
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
Log.Error("Not all obsolte log files could be deleted successfully. {@l_oException}", l_oException);
|
||||
}
|
||||
|
||||
if (loggerConfiguration == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (loggerConfiguration == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return loggerConfiguration.File(
|
||||
new JsonFormatter(),
|
||||
DirectoryManager.LogFileName,
|
||||
fileSizeLimitBytes: MAXLOGFILESSIZEBYTESBYTES / RETAINEDFILECOUNT,
|
||||
/*shared: true, // Leads to exception if activated.*/
|
||||
rollingInterval: Serilog.RollingInterval.Infinite,
|
||||
retainedFileCountLimit: retainedFilesCountLimit);
|
||||
}
|
||||
return loggerConfiguration.File(
|
||||
new JsonFormatter(),
|
||||
DirectoryManager.LogFileName,
|
||||
fileSizeLimitBytes: MAXLOGFILESSIZEBYTESBYTES / RETAINEDFILECOUNT,
|
||||
/*shared: true, // Leads to exception if activated.*/
|
||||
rollingInterval: Serilog.RollingInterval.Infinite,
|
||||
retainedFileCountLimit: retainedFilesCountLimit);
|
||||
}
|
||||
|
||||
/// <summary> Gets all log files in logging directory. </summary>
|
||||
/// <param name="p_oLogger"></param>
|
||||
/// <returns>List of log files.</returns>
|
||||
public static IList<string> GetLogFiles(this ILogger p_oLogger)
|
||||
{
|
||||
try
|
||||
{
|
||||
return DirectoryManager.GetLogFiles();
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
Log.Error("Getting list of log files failed. Empty list is returned instead. {@l_oException}", l_oException);
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
/// <summary> Gets all log files in logging directory. </summary>
|
||||
/// <param name="p_oLogger"></param>
|
||||
/// <returns>List of log files.</returns>
|
||||
public static IList<string> GetLogFiles(this ILogger p_oLogger)
|
||||
{
|
||||
try
|
||||
{
|
||||
return DirectoryManager.GetLogFiles();
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
Log.Error("Getting list of log files failed. Empty list is returned instead. {@l_oException}", l_oException);
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets path where log files are located. </summary>
|
||||
/// <param name="p_oLogger"></param>
|
||||
/// <returns>List of log files.</returns>
|
||||
public static string GetLogFilePath(
|
||||
this ILogger p_oLogger)
|
||||
{
|
||||
return DirectoryManager.LogFilePath;
|
||||
}
|
||||
}
|
||||
/// <summary> Gets path where log files are located. </summary>
|
||||
/// <param name="p_oLogger"></param>
|
||||
/// <returns>List of log files.</returns>
|
||||
public static string GetLogFilePath(
|
||||
this ILogger p_oLogger)
|
||||
{
|
||||
return DirectoryManager.LogFilePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,143 +4,143 @@ using System.Linq;
|
|||
|
||||
namespace TINK.Model.Logging
|
||||
{
|
||||
public class LoggingDirectoryManager : ILoggingDirectoryManager
|
||||
{
|
||||
/// <summary> Name of logging subdirectory.</summary>
|
||||
private const string LOGDIRECTORYTITLE = "Log";
|
||||
public class LoggingDirectoryManager : ILoggingDirectoryManager
|
||||
{
|
||||
/// <summary> Name of logging subdirectory.</summary>
|
||||
private const string LOGDIRECTORYTITLE = "Log";
|
||||
|
||||
/// <summary> Prevents an invalid instance to be created. </summary>
|
||||
private LoggingDirectoryManager() { }
|
||||
/// <summary> Prevents an invalid instance to be created. </summary>
|
||||
private LoggingDirectoryManager() { }
|
||||
|
||||
public LoggingDirectoryManager(
|
||||
Func<string, IList<string>> fileListProvider,
|
||||
Func<string, bool> directoryExistsChecker,
|
||||
Action<string> directoryCreator,
|
||||
Action<string> fileEraser,
|
||||
string logFilePath,
|
||||
char directorySeparatorChar,
|
||||
int p_iRetainedFilesCountLimit)
|
||||
{
|
||||
m_oFileListProvider = fileListProvider ?? throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. File list provider delegate can not be null.");
|
||||
public LoggingDirectoryManager(
|
||||
Func<string, IList<string>> fileListProvider,
|
||||
Func<string, bool> directoryExistsChecker,
|
||||
Action<string> directoryCreator,
|
||||
Action<string> fileEraser,
|
||||
string logFilePath,
|
||||
char directorySeparatorChar,
|
||||
int p_iRetainedFilesCountLimit)
|
||||
{
|
||||
m_oFileListProvider = fileListProvider ?? throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. File list provider delegate can not be null.");
|
||||
|
||||
if (directoryExistsChecker == null)
|
||||
{
|
||||
throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Directory existance checker delegate can not be null.");
|
||||
}
|
||||
if (directoryExistsChecker == null)
|
||||
{
|
||||
throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Directory existance checker delegate can not be null.");
|
||||
}
|
||||
|
||||
if (directoryCreator == null)
|
||||
{
|
||||
throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Directory creator delegate can not be null.");
|
||||
}
|
||||
if (directoryCreator == null)
|
||||
{
|
||||
throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Directory creator delegate can not be null.");
|
||||
}
|
||||
|
||||
m_oFileEraser = fileEraser ?? throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. File eraser delegate can not be null.");
|
||||
m_oFileEraser = fileEraser ?? throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. File eraser delegate can not be null.");
|
||||
|
||||
if (string.IsNullOrEmpty(logFilePath))
|
||||
{
|
||||
throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Log file path can not be null or empty.");
|
||||
}
|
||||
if (string.IsNullOrEmpty(logFilePath))
|
||||
{
|
||||
throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Log file path can not be null or empty.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(directorySeparatorChar.ToString()))
|
||||
{
|
||||
throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Directory separtor character can not be null or empty.");
|
||||
}
|
||||
if (string.IsNullOrEmpty(directorySeparatorChar.ToString()))
|
||||
{
|
||||
throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Directory separtor character can not be null or empty.");
|
||||
}
|
||||
|
||||
if (p_iRetainedFilesCountLimit < 1)
|
||||
{
|
||||
throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Count of retained log files is {p_iRetainedFilesCountLimit} but must be equal or larger one.");
|
||||
}
|
||||
if (p_iRetainedFilesCountLimit < 1)
|
||||
{
|
||||
throw new ArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Count of retained log files is {p_iRetainedFilesCountLimit} but must be equal or larger one.");
|
||||
}
|
||||
|
||||
DirectorySeparatorChar = directorySeparatorChar.ToString();
|
||||
DirectorySeparatorChar = directorySeparatorChar.ToString();
|
||||
|
||||
LogFilePath = $"{logFilePath}{DirectorySeparatorChar}{LOGDIRECTORYTITLE}";
|
||||
LogFilePath = $"{logFilePath}{DirectorySeparatorChar}{LOGDIRECTORYTITLE}";
|
||||
|
||||
|
||||
m_iRetainedFilesCountLimit = p_iRetainedFilesCountLimit;
|
||||
m_iRetainedFilesCountLimit = p_iRetainedFilesCountLimit;
|
||||
|
||||
if (string.IsNullOrEmpty(LogFileTitle))
|
||||
{
|
||||
LogFileTitle = $"{DateTime.Now:yyyy_MM_dd_HH_mm_ss}.jsnl";
|
||||
}
|
||||
if (string.IsNullOrEmpty(LogFileTitle))
|
||||
{
|
||||
LogFileTitle = $"{DateTime.Now:yyyy_MM_dd_HH_mm_ss}.jsnl";
|
||||
}
|
||||
|
||||
// Create directory if direcotry does not exist.
|
||||
if (directoryExistsChecker(LogFilePath) == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
directoryCreator(LogFilePath);
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
// Create directory if direcotry does not exist.
|
||||
if (directoryExistsChecker(LogFilePath) == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
directoryCreator(LogFilePath);
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
|
||||
throw new FileOperationException($"Logging directory {LogFilePath} could not be created successfully.", l_oException);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new FileOperationException($"Logging directory {LogFilePath} could not be created successfully.", l_oException);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Deletes files which are out of retainment scope. </summary>
|
||||
public void DeleteObsoleteLogs()
|
||||
{
|
||||
var l_oExceptions = new List<Exception>();
|
||||
var l_oSortedFileArray = m_oFileListProvider(LogFilePath).OrderByDescending(x => x).ToArray();
|
||||
/// <summary> Deletes files which are out of retainment scope. </summary>
|
||||
public void DeleteObsoleteLogs()
|
||||
{
|
||||
var l_oExceptions = new List<Exception>();
|
||||
var l_oSortedFileArray = m_oFileListProvider(LogFilePath).OrderByDescending(x => x).ToArray();
|
||||
|
||||
for (int l_iIndex = l_oSortedFileArray.Length - 1;
|
||||
l_iIndex >= m_iRetainedFilesCountLimit - 1; /* files remaining count must be m_iRetainedFilesCountLimit - 1 because new log file will be added afterwards */
|
||||
l_iIndex--)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_oFileEraser(l_oSortedFileArray[l_iIndex]);
|
||||
}
|
||||
catch (Exception l_oExpetion)
|
||||
{
|
||||
// Getting list of log files found.
|
||||
l_oExceptions.Add(l_oExpetion);
|
||||
}
|
||||
}
|
||||
for (int l_iIndex = l_oSortedFileArray.Length - 1;
|
||||
l_iIndex >= m_iRetainedFilesCountLimit - 1; /* files remaining count must be m_iRetainedFilesCountLimit - 1 because new log file will be added afterwards */
|
||||
l_iIndex--)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_oFileEraser(l_oSortedFileArray[l_iIndex]);
|
||||
}
|
||||
catch (Exception l_oExpetion)
|
||||
{
|
||||
// Getting list of log files found.
|
||||
l_oExceptions.Add(l_oExpetion);
|
||||
}
|
||||
}
|
||||
|
||||
if (l_oExceptions.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (l_oExceptions.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
throw new AggregateException("Deleting obsolete log files failed.", l_oExceptions.ToArray());
|
||||
}
|
||||
throw new AggregateException("Deleting obsolete log files failed.", l_oExceptions.ToArray());
|
||||
}
|
||||
|
||||
/// <summary> Gets all log files in logging directory. </summary>
|
||||
/// <param name="p_oLogger"></param>
|
||||
/// <returns>List of log files.</returns>
|
||||
public IList<string> GetLogFiles()
|
||||
{
|
||||
try
|
||||
{
|
||||
return m_oFileListProvider(LogFilePath).OrderBy(x => x).ToList();
|
||||
}
|
||||
catch (Exception l_oExpetion)
|
||||
{
|
||||
// Getting list of log files found.
|
||||
throw new FileOperationException("Getting list of log files failed.", l_oExpetion);
|
||||
}
|
||||
}
|
||||
/// <summary> Gets all log files in logging directory. </summary>
|
||||
/// <param name="p_oLogger"></param>
|
||||
/// <returns>List of log files.</returns>
|
||||
public IList<string> GetLogFiles()
|
||||
{
|
||||
try
|
||||
{
|
||||
return m_oFileListProvider(LogFilePath).OrderBy(x => x).ToList();
|
||||
}
|
||||
catch (Exception l_oExpetion)
|
||||
{
|
||||
// Getting list of log files found.
|
||||
throw new FileOperationException("Getting list of log files failed.", l_oExpetion);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Holds delegate to provide file names.</summary>
|
||||
private readonly Func<string, IList<string>> m_oFileListProvider;
|
||||
/// <summary>Holds delegate to provide file names.</summary>
|
||||
private readonly Func<string, IList<string>> m_oFileListProvider;
|
||||
|
||||
/// <summary>Holds delegate to delete files.</summary>
|
||||
private readonly Action<string> m_oFileEraser;
|
||||
/// <summary>Holds delegate to delete files.</summary>
|
||||
private readonly Action<string> m_oFileEraser;
|
||||
|
||||
/// <summary>Holds delegate to provide file names.</summary>
|
||||
private int m_iRetainedFilesCountLimit;
|
||||
/// <summary>Holds delegate to provide file names.</summary>
|
||||
private int m_iRetainedFilesCountLimit;
|
||||
|
||||
/// <summary> Holds the log file name. </summary>
|
||||
private string LogFileTitle { get; }
|
||||
/// <summary> Holds the log file name. </summary>
|
||||
private string LogFileTitle { get; }
|
||||
|
||||
/// <summary> Holds the log file name. </summary>
|
||||
public string LogFilePath { get; }
|
||||
/// <summary> Holds the log file name. </summary>
|
||||
public string LogFilePath { get; }
|
||||
|
||||
/// <summary> Holds the directory separator character. </summary>
|
||||
private string DirectorySeparatorChar { get; }
|
||||
/// <summary> Holds the directory separator character. </summary>
|
||||
private string DirectorySeparatorChar { get; }
|
||||
|
||||
/// <summary> Holds the log file name. </summary>
|
||||
public string LogFileName { get { return $"{LogFilePath}{DirectorySeparatorChar}{LogFileTitle}"; } }
|
||||
}
|
||||
/// <summary> Holds the log file name. </summary>
|
||||
public string LogFileName { get { return $"{LogFilePath}{DirectorySeparatorChar}{LogFileTitle}"; } }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue