-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWimaLogger.cs
24 lines (18 loc) · 1.22 KB
/
WimaLogger.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using Microsoft.Extensions.Logging;
using CM = Common.Logging;
namespace Wima.Log
{
public class WimaLogger : WimaLoggerBase, ILogger
{
public WimaLogger(Type t) : base(t) { }
public WimaLogger(object o) : base(o) { }
public WimaLogger(string logName, CM.LogLevel? logLevel = null, bool showLevel = true, bool showDateTime = true, bool showLogName = true, string dateTimeFormat = DEFAULT_LOGLINE_TIME_FORMAT, LogMode? logMode = null)
: base(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat, logMode) { }
public IDisposable BeginScope<TState>(TState state) where TState : notnull => default!;
public bool IsEnabled(LogLevel logLevel) => LogLevel.HasFlag(logLevel.Map2CommonLogLevel());
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter = null)
=> WriteInternal(logLevel.Map2CommonLogLevel(),
$"[{eventId.Id}]\t{(string.IsNullOrEmpty(eventId.Name) ? "" : "[" + eventId.Name + "]")}\t{(formatter == null ? state.ToString() : formatter(state, exception))}",
exception);
}
}