This commit is contained in:
2023-01-27 11:25:44 +01:00
parent a3facd8bc2
commit 2630f859ea
6 changed files with 166 additions and 27 deletions

View File

@@ -25,8 +25,9 @@ namespace EonaCat.logger.Managers
/// <param name="settings">Logger settings</param>
/// <param name="logType">logtype for the formatted message</param>
/// <param name="currentMessage">The actual message to format with the header</param>
/// <param name="dateTime">The dateTime of the message</param>
/// <returns></returns>
public static string FormatMessageWithHeader(LoggerSettings settings, ELogType logType, string currentMessage)
public static string FormatMessageWithHeader(LoggerSettings settings, ELogType logType, string currentMessage, DateTime dateTime)
{
if (string.IsNullOrWhiteSpace(currentMessage))
{
@@ -41,7 +42,7 @@ namespace EonaCat.logger.Managers
string header = settings.HeaderFormat;
if (header.Contains("{ts}"))
{
header = header.Replace("{ts}", DateTime.Now.ToUniversalTime().ToString(settings.TimestampFormat));
header = header.Replace("{ts}", dateTime.ToString(settings.TimestampFormat));
}
if (header.Contains("{host}"))
@@ -209,7 +210,6 @@ namespace EonaCat.logger.Managers
if (settings == null) return;
if (!settings.EnableFileLogging) return;
if (string.IsNullOrWhiteSpace(message)) return;
//logger.LogInformation(message);
int tries = 0;
bool completed = false;