Skip to content
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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

RudyBricks
Copy link

This allows for the injection of task category numbers. You can see these numbers afterwards in the ¨Task Category¨ column within the event viewer.

Copy link
Member

@nblumhardt nblumhardt left a 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)
Copy link
Member

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?

Copy link
Author

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\" />
Copy link
Member

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.

Copy link
Author

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())
{
}

Copy link
Member

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)
Copy link
Member

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();

Copy link
Author

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
{

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - extra whitespace.

Copy link
Author

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - 2025 or just ©️

Copy link
Author

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

@RudyBricks RudyBricks requested a review from nblumhardt January 24, 2025 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants