This repository was archived by the owner on Dec 13, 2018. It is now read-only.
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
Changes to Logging API surface #331
Closed
Description
- Have all levels (
Critical
,Debug
,Error
,Warning
,Information
,Verbose
) have the same overloads as extension methods:Log....(this ILogger logger, EventId eventId, Exception exception, string message, params object[] args);
Log....(this ILogger logger, EventId eventId, string message, params object[] args);
Log....(this ILogger logger, string message, params object[] args);
EventId
has implicit conversion from/to Int and if you want to use string, you do the conversion yourself- Our frameworks will be passing in both
int
andstring
basedEventId
s. - Event IDs (string versions) in our frameworks should be PascalCased and should typically be two words. Some examples:
- "QueryExecuting"
- "ActionExecuting"
- "ContentNegotiationFailed"
- ...
- Change the
LoggerMessage.Define
to take anEventId
instead ofint
- There may be other places where
int eventId
could be used. Convert them to EventId.
- There may be other places where
MessageFormatter
should be state tostring
(and not do formatting at all)MessageFormatter
state should never be null, null check shouldn’t be done in runtime- Remove
ILogValues
and useIReadOnlyList<KeyValuePair<string, object>>
ILogger
change: Instead ofvoid Log(LogLevel logLevel, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
we should usevoid Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)