-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for task category injection #59
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks! 👍
The assembly version/version prefix in the .CSPROJ would need to be updated to v5 since the addition of a parameter is a binary breaking change.
@@ -55,7 +56,8 @@ public static LoggerConfiguration EventLog( | |||
string outputTemplate = DefaultOutputTemplate, | |||
IFormatProvider? formatProvider = null, | |||
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, | |||
IEventIdProvider? eventIdProvider = null) | |||
IEventIdProvider? eventIdProvider = null, | |||
ICategoryNumberProvider? categoryNumberProvider = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the EventLog.WriteEvent
API, the category is referred to as just category
(rather than categoryNumber
) - perhaps ICategoryProvider
, or IEventLogCategoryProvider
would be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed it to ICategoryProvider.
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Properties\PublishProfiles\" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, don't need to include this folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, deleted these entries again.
: this(source, logName, textFormatter, machineName, manageEventSource, new EventIdHashProvider()) | ||
{ | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
{ | ||
if (source == null) throw new ArgumentNullException(nameof(source)); | ||
if (textFormatter == null) throw new ArgumentNullException(nameof(textFormatter)); | ||
if (eventIdProvider == null) throw new ArgumentNullException(nameof(eventIdProvider)); | ||
if (eventIdProvider == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of reassigning the parameters, it might be clearer to just use null coalescing for the assignments below -
_eventIdProvider = eventIdProvider ?? new EventIdHashProvider();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point - replaced with null coalescing
/// </summary> | ||
sealed class NullCategoryNumberProvider : ICategoryNumberProvider | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit - extra whitespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the extra white space
@@ -0,0 +1,31 @@ | |||
// Copyright 2016 Serilog Contributors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit - 2025 or just ©️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to 2025 on all new files in this PR
This allows for the injection of task category numbers. You can see these numbers afterwards in the ¨Task Category¨ column within the event viewer.