mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-20 03:56:29 +02:00
Code updated to 3.0.238
This commit is contained in:
parent
3302d80678
commit
9c6a1fa92b
257 changed files with 7763 additions and 2861 deletions
|
@ -18,61 +18,61 @@ namespace TINK.Model.Logging
|
|||
public static class LoggerConfigurationHelper
|
||||
{
|
||||
/// <summary> Holds the log file name. </summary>
|
||||
private static ILoggingDirectoryManager m_oDirectoryManager = new EmptyDirectoryLoggingManger();
|
||||
private static ILoggingDirectoryManager DirectoryManager { get; set; } = new EmptyDirectoryLoggingManger();
|
||||
|
||||
/// <summary> Sets up logging to file.</summary>
|
||||
/// <param name="p_oLoggerConfiguration">Object to set up logging with.</param>
|
||||
/// <param name="loggerConfiguration">Object to set up logging with.</param>
|
||||
/// <param name="p_oDevice">Object to get file informaton from.</param>
|
||||
/// <param name="p_oRollingInterval">Specifies rolling type.</param>
|
||||
/// <param name="p_iRetainedFilesCountLimit">Count of file being retained.</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 p_oLoggerConfiguration,
|
||||
string p_strLogFileFolder,
|
||||
RollingInterval p_oRollingInterval = RollingInterval.Session,
|
||||
int p_iRetainedFilesCountLimit = 10)
|
||||
this LoggerSinkConfiguration loggerConfiguration,
|
||||
string logFileFolder,
|
||||
RollingInterval rollingInterval = RollingInterval.Session,
|
||||
int retainedFilesCountLimit = 10)
|
||||
{
|
||||
if (m_oDirectoryManager is EmptyDirectoryLoggingManger)
|
||||
if (DirectoryManager is EmptyDirectoryLoggingManger)
|
||||
{
|
||||
// Roll file only once per app session.
|
||||
try
|
||||
{
|
||||
m_oDirectoryManager = new LoggingDirectoryManager(
|
||||
DirectoryManager = new LoggingDirectoryManager(
|
||||
Directory.GetFiles,
|
||||
Directory.Exists,
|
||||
(path) => Directory.CreateDirectory(path),
|
||||
System.IO.File.Delete,
|
||||
p_strLogFileFolder,
|
||||
logFileFolder,
|
||||
Path.DirectorySeparatorChar,
|
||||
p_iRetainedFilesCountLimit);
|
||||
retainedFilesCountLimit);
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
Log.Error("Log directory manager could not be instanciated successfully. {@l_oException}", l_oException);
|
||||
m_oDirectoryManager = new EmptyDirectoryLoggingManger();
|
||||
DirectoryManager = new EmptyDirectoryLoggingManger();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m_oDirectoryManager.DeleteObsoleteLogs();
|
||||
DirectoryManager.DeleteObsoleteLogs();
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
Log.Error("Not all obsolte log files could be deleted successfully. {@l_oException}", l_oException);
|
||||
}
|
||||
|
||||
if (p_oLoggerConfiguration == null)
|
||||
if (loggerConfiguration == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return p_oLoggerConfiguration.File(
|
||||
return loggerConfiguration.File(
|
||||
new JsonFormatter(),
|
||||
m_oDirectoryManager.LogFileName,
|
||||
DirectoryManager.LogFileName,
|
||||
/*shared: true, // Leads to exception if activated.*/
|
||||
rollingInterval: Serilog.RollingInterval.Infinite,
|
||||
retainedFileCountLimit: p_iRetainedFilesCountLimit);
|
||||
retainedFileCountLimit: retainedFilesCountLimit);
|
||||
}
|
||||
|
||||
/// <summary> Gets all log files in logging directory. </summary>
|
||||
|
@ -82,7 +82,7 @@ namespace TINK.Model.Logging
|
|||
{
|
||||
try
|
||||
{
|
||||
return m_oDirectoryManager.GetLogFiles();
|
||||
return DirectoryManager.GetLogFiles();
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ namespace TINK.Model.Logging
|
|||
public static string GetLogFilePath(
|
||||
this ILogger p_oLogger)
|
||||
{
|
||||
return m_oDirectoryManager.LogFilePath;
|
||||
return DirectoryManager.LogFilePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue