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

Log event ids introduced for important log statements #331

Merged
merged 147 commits into from
Oct 20, 2023

Conversation

NikolaVetnic
Copy link
Contributor

Readiness checklist

  • I added/updated unit tests.
  • I added/updated integration tests.
  • I ensured that the PR title is good enough for the changelog.
  • I labeled the PR.

Description

1 How It Works

Specific log event ids accompanied by log event names are added to important log statements to facilitate filtering and search. A pattern involving an ILogger extension containing a private delegate and a public method is used, e.g.:

file static class LoggerExtensions
{
    private static readonly Action<ILogger, TokenId, Exception> NO_BLOB_FOR_TOKEN_ID =
        LoggerMessage.Define<TokenId>(
            LogLevel.Error,
            new EventId(826083, "Tokens.SanityCheck.NoBlobForTokenId"),
            "No blob found for token id: '{tokenId}'."
        );

    public static void NoBlobForTokenId(this ILogger logger, TokenId tokenId)
    {
        NO_BLOB_FOR_TOKEN_ID(logger, tokenId, default!);
    }
}

This way the methods introduced for logging the events in a certain class are only available in that class.

2 Where Is It Used

Introduced the log event ids as well as corrected occasional typos in the following classes: CustomExceptionsFilter, LoggingBehavior, EventBusAzureServiceBus, EventBusGoogleCloudPubSub, DefaultRabbitMQPersisterConnection, EventBusRabbitMQ, AzureStorageAccount, GoogleCloudStorage, Modules.Devices.Application.Clients.Commands.DeleteClient.Handler, Modules.Devices.Application.Devices.Commands.ChangePassword.Handler, Modules.Devices.Application.Devices.Commands.DeleteDevice.Handler, Modules.Devices.Application.Devices.Commands.RegisterDevice.Handler, Modules.Devices.Application.Identities.Commands.CreateIdentity.Handler, Modules.Devices.Application.Tiers.Commands.CreateTier, AzureNotificationHubPushService, DirectPushService, Modules.Files.Jobs.SanityCheck.Infrastructure.Reporter.LogReporter, Modules.Messages.Jobs.SanityCheck.Infrastructure.Reporter.LogReporter, IdentityCreatedIntegrationEventHandler, TierCreatedIntegrationEventHandler, TierDeletedIntegrationEventHandler, TierQuotaDefinitionDeletedIntegrationEventHandler, Quotas.Application.Tiers.Commands.CreateQuotaForIdentity.Handler, Quotas.Application.Tiers.Commands.CreateQuotaForTier.Handler, Quotas.Application.Tiers.Commands.DeleteQuotaForIdentity.Handler, Quotas.Application.Tiers.Commands.DeleteTierQuotaDefinition.Handler, RelationshipsRepository, Relationships.Jobs.SanityCheck.RelationshipChange.Infrastructure.Reporter.LogReporter, Relationships.Jobs.SanityCheck.RelationshipTemplate.Infrastructure.Reporter.LogReporter, Synchronization.Jobs.SanityCheck.Infrastructure.Reporter.LogReporter, Tokens.Jobs.SanityCheck.Infrastructure.Reporter.LogReporter.

Complete list with all the introduced log event ids and names will be available in documentation.

@NikolaVetnic NikolaVetnic requested a review from tnotheis October 20, 2023 11:28
@NikolaVetnic NikolaVetnic merged commit 34687df into main Oct 20, 2023
18 checks passed
@NikolaVetnic NikolaVetnic deleted the introduce-log-event-ids branch October 20, 2023 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants