diff --git a/EonaCat.Logger/EonaCat.Logger.csproj b/EonaCat.Logger/EonaCat.Logger.csproj
index 961f24a..d77f662 100644
--- a/EonaCat.Logger/EonaCat.Logger.csproj
+++ b/EonaCat.Logger/EonaCat.Logger.csproj
@@ -9,7 +9,7 @@
net7.0;
icon.ico
- 1.0.5
+ 1.0.6
EonaCat (Jeroen Saey)
true
EonaCat (Jeroen Saey)
diff --git a/EonaCat.Logger/Managers/ILogManager.cs b/EonaCat.Logger/Managers/ILogManager.cs
index 755b223..8362d39 100644
--- a/EonaCat.Logger/Managers/ILogManager.cs
+++ b/EonaCat.Logger/Managers/ILogManager.cs
@@ -2,6 +2,6 @@
{
public interface ILogManager
{
- void Write(string message, ELogType logType = ELogType.INFO, ELogType? logLevel = null);
+ void Write(string message, ELogType logType = ELogType.INFO, ELogType? logLevel = null, bool? writeToConsole = null);
}
}
\ No newline at end of file
diff --git a/EonaCat.Logger/Managers/LogHelper.cs b/EonaCat.Logger/Managers/LogHelper.cs
index 2479abb..4b793b4 100644
--- a/EonaCat.Logger/Managers/LogHelper.cs
+++ b/EonaCat.Logger/Managers/LogHelper.cs
@@ -146,10 +146,10 @@ namespace EonaCat.logger.Managers
return message;
}
- internal static void SendConsole(LoggerSettings settings, ELogType logType, string message)
+ internal static void SendConsole(LoggerSettings settings, ELogType logType, string message, bool writeToConsole)
{
if (settings == null) return;
- if (!settings.EnableConsole) return;
+ if (!writeToConsole) return;
if (string.IsNullOrWhiteSpace(message)) return;
if (settings.EnableColors)
diff --git a/EonaCat.Logger/Managers/LogManager.cs b/EonaCat.Logger/Managers/LogManager.cs
index dd8ab1a..3c8d5e5 100644
--- a/EonaCat.Logger/Managers/LogManager.cs
+++ b/EonaCat.Logger/Managers/LogManager.cs
@@ -7,11 +7,8 @@ using EonaCatLogger.EonaCatCoreLogger.Models;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
-using System.Collections;
using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
-using System.Net;
using System.Threading;
using System.Threading.Tasks;
@@ -151,7 +148,7 @@ namespace EonaCat.Logger.Managers
}
}
- private void Write(DateTime dateTime, string message, ELogType logType = ELogType.INFO)
+ private void Write(DateTime dateTime, string message, ELogType logType = ELogType.INFO, bool? writeToConsole = null)
{
if (string.IsNullOrWhiteSpace(message)) return;
if (logType < ELogType.INFO) return;
@@ -171,7 +168,12 @@ namespace EonaCat.Logger.Managers
var fullMessage = LogHelper.FormatMessageWithHeader(_settings, logType, currentMessage, dateTime);
- LogHelper.SendConsole(_settings, logType, fullMessage);
+ if (writeToConsole == null)
+ {
+ writeToConsole = _settings.EnableConsole;
+ }
+
+ LogHelper.SendConsole(_settings, logType, fullMessage, writeToConsole == true);
LogHelper.SendFile(Logger, _settings, logType, fullMessage);
@@ -179,7 +181,7 @@ namespace EonaCat.Logger.Managers
if (!string.IsNullOrEmpty(remainder))
{
- Write(dateTime, remainder, logType);
+ Write(dateTime, remainder, logType, writeToConsole);
}
var EonaCatMessage = new EonaCatLogMessage
@@ -285,13 +287,13 @@ namespace EonaCat.Logger.Managers
SetupLogManager();
}
- public void Write(Exception exception, string module = null, string method = null, bool criticalException = false)
+ public void Write(Exception exception, string module = null, string method = null, bool criticalException = false, bool? writeToConsole = null)
{
- if (exception != null) return;
- Write(exception.FormatExceptionToMessage(module, method), criticalException ? ELogType.CRITICAL : ELogType.ERROR);
+ if (exception == null) return;
+ Write(exception.FormatExceptionToMessage(module, method), criticalException ? ELogType.CRITICAL : ELogType.ERROR, null, writeToConsole);
}
- public void Write(string message, ELogType logType = ELogType.INFO, ELogType? logLevel = null)
+ public void Write(string message, ELogType logType = ELogType.INFO, ELogType? logLevel = null, bool? writeToConsole = null)
{
lock (_batton)
{
@@ -314,7 +316,7 @@ namespace EonaCat.Logger.Managers
StartNewLog();
}
- Write(now, message, logType);
+ Write(now, message, logType, writeToConsole);
}
}
}