Skip to content

Commit c5e440b

Browse files
Fix logging adaptor
1 parent 9b9472b commit c5e440b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/Certify.Shared/Utils/Loggy.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,28 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
6363
}
6464
}
6565

66-
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter) => throw new NotImplementedException();
66+
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
67+
{
68+
69+
var message = formatter(state, exception);
70+
71+
switch (logLevel)
72+
{
73+
case LogLevel.Critical:
74+
case LogLevel.Error:
75+
_log.Error(exception, message);
76+
break;
77+
case LogLevel.Warning:
78+
_log.Warning(message);
79+
break;
80+
case LogLevel.Information:
81+
_log.Information(message);
82+
break;
83+
case LogLevel.Debug:
84+
case LogLevel.Trace:
85+
_log.Debug(message);
86+
break;
87+
}
88+
}
6789
}
6890
}

0 commit comments

Comments
 (0)