Updated
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
net7.0;
|
net7.0;
|
||||||
</TargetFrameworks>
|
</TargetFrameworks>
|
||||||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||||
<Version>1.0.5</Version>
|
<Version>1.0.6</Version>
|
||||||
<Authors>EonaCat (Jeroen Saey)</Authors>
|
<Authors>EonaCat (Jeroen Saey)</Authors>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Company>EonaCat (Jeroen Saey)</Company>
|
<Company>EonaCat (Jeroen Saey)</Company>
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
{
|
{
|
||||||
public interface ILogManager
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,10 +146,10 @@ namespace EonaCat.logger.Managers
|
|||||||
return message;
|
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 == null) return;
|
||||||
if (!settings.EnableConsole) return;
|
if (!writeToConsole) return;
|
||||||
if (string.IsNullOrWhiteSpace(message)) return;
|
if (string.IsNullOrWhiteSpace(message)) return;
|
||||||
|
|
||||||
if (settings.EnableColors)
|
if (settings.EnableColors)
|
||||||
|
|||||||
@@ -7,11 +7,8 @@ using EonaCatLogger.EonaCatCoreLogger.Models;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
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 (string.IsNullOrWhiteSpace(message)) return;
|
||||||
if (logType < ELogType.INFO) return;
|
if (logType < ELogType.INFO) return;
|
||||||
@@ -171,7 +168,12 @@ namespace EonaCat.Logger.Managers
|
|||||||
|
|
||||||
var fullMessage = LogHelper.FormatMessageWithHeader(_settings, logType, currentMessage, dateTime);
|
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);
|
LogHelper.SendFile(Logger, _settings, logType, fullMessage);
|
||||||
|
|
||||||
@@ -179,7 +181,7 @@ namespace EonaCat.Logger.Managers
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(remainder))
|
if (!string.IsNullOrEmpty(remainder))
|
||||||
{
|
{
|
||||||
Write(dateTime, remainder, logType);
|
Write(dateTime, remainder, logType, writeToConsole);
|
||||||
}
|
}
|
||||||
|
|
||||||
var EonaCatMessage = new EonaCatLogMessage
|
var EonaCatMessage = new EonaCatLogMessage
|
||||||
@@ -285,13 +287,13 @@ namespace EonaCat.Logger.Managers
|
|||||||
SetupLogManager();
|
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;
|
if (exception == null) return;
|
||||||
Write(exception.FormatExceptionToMessage(module, method), criticalException ? ELogType.CRITICAL : ELogType.ERROR);
|
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)
|
lock (_batton)
|
||||||
{
|
{
|
||||||
@@ -314,7 +316,7 @@ namespace EonaCat.Logger.Managers
|
|||||||
StartNewLog();
|
StartNewLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
Write(now, message, logType);
|
Write(now, message, logType, writeToConsole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user