Skip to content

Commit a5a1bb0

Browse files
committed
Improve logging consistency and fix typos in event IDs and messages across connectors.
1 parent 3f1f056 commit a5a1bb0

6 files changed

Lines changed: 22 additions & 21 deletions

File tree

src/Deveel.Messaging.Connector.Abstractions/Messaging/ChannelConnectorBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ protected async Task<ConnectorResult<bool>> RefreshAuthenticationAsync(Cancellat
272272

273273
if (authConfig == null)
274274
{
275-
Logger.LogAuthenticationConfigurationNotFound(_authenticationCredential.AuthenticationType);
275+
Logger.LogAuthenticationConfigurationNotFoundForType(_authenticationCredential.AuthenticationType);
276276
return await AuthenticateAsync(cancellationToken);
277277
}
278278

src/Deveel.Messaging.Connector.Abstractions/Messaging/ConnectorLoggerEventId.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ internal static class ConnectorLoggerEventId
44
{
55
public const int StartingAuthentication = LoggerEventId.BaseId + 10;
66
public const int NoAuthenticationConfigurationFound = LoggerEventId.BaseId + 11;
7-
public const int UsingAuthenticationConfiguration = LoggerEventId.BaseId + 12;
8-
public const int AuthenticationSuccessful = LoggerEventId.BaseId + 13;
9-
public const int AuthenticationFailed = LoggerEventId.BaseId + 14;
10-
public const int AuthenticationException = LoggerEventId.BaseId + 15;
11-
public const int NoCredentialToRefresh = LoggerEventId.BaseId + 16;
12-
public const int RefreshingAuthenticationCredential = LoggerEventId.BaseId + 17;
13-
public const int AuthenticationCredentialRefreshed = LoggerEventId.BaseId + 18;
14-
public const int AuthenticationCredentialRefreshFailed = LoggerEventId.BaseId + 19;
15-
public const int AuthenticationCredentialRefreshException = LoggerEventId.BaseId + 20;
7+
public const int NoAuthenticationConfigurationFoundForType = LoggerEventId.BaseId + 12;
8+
public const int UsingAuthenticationConfiguration = LoggerEventId.BaseId + 13;
9+
public const int AuthenticationSuccessful = LoggerEventId.BaseId + 14;
10+
public const int AuthenticationFailed = LoggerEventId.BaseId + 15;
11+
public const int AuthenticationException = LoggerEventId.BaseId + 16;
12+
public const int NoCredentialToRefresh = LoggerEventId.BaseId + 17;
13+
public const int RefreshingAuthenticationCredential = LoggerEventId.BaseId + 18;
14+
public const int AuthenticationCredentialRefreshed = LoggerEventId.BaseId + 19;
15+
public const int AuthenticationCredentialRefreshFailed = LoggerEventId.BaseId + 20;
16+
public const int AuthenticationCredentialRefreshException = LoggerEventId.BaseId + 21;
1617

1718
public const int CheckingHealth = LoggerEventId.BaseId + 25;
1819
public const int HealthCheckSuccessful = LoggerEventId.BaseId + 26;

src/Deveel.Messaging.Connector.Abstractions/Messaging/LoggerExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ internal static partial class LoggerExtensions
6363
internal static partial void LogRefreshingAuthenticationCredential(this ILogger logger);
6464

6565
[LoggerMessage(
66-
EventId = ConnectorLoggerEventId.NoAuthenticationConfigurationFound,
66+
EventId = ConnectorLoggerEventId.NoAuthenticationConfigurationFoundForType,
6767
Level = LogLevel.Warning,
68-
Message = "Authentication configuration not found for credential type: {AuthenticationType}")]
69-
internal static partial void LogAuthenticationConfigurationNotFound(this ILogger logger, AuthenticationType authenticationType);
68+
Message = "Authentication configuration not found for credential type {AuthenticationType}")]
69+
internal static partial void LogAuthenticationConfigurationNotFoundForType(this ILogger logger, AuthenticationType authenticationType);
7070

7171
[LoggerMessage(
7272
EventId = ConnectorLoggerEventId.AuthenticationCredentialRefreshed,
@@ -144,8 +144,8 @@ internal static partial class LoggerExtensions
144144

145145
[LoggerMessage(
146146
EventId = ConnectorLoggerEventId.StatusRead,
147-
Level = LogLevel.Error,
148-
Message = "Failed to read connector status")]
147+
Level = LogLevel.Information,
148+
Message = "Connector status read")]
149149
internal static partial void LogStatusRead(this ILogger logger);
150150

151151
[LoggerMessage(
@@ -163,7 +163,7 @@ internal static partial class LoggerExtensions
163163
[LoggerMessage(
164164
EventId = ConnectorLoggerEventId.HealthCheckSuccessful,
165165
Level = LogLevel.Information,
166-
Message = "Connector health check was succesful")]
166+
Message = "Connector health check was successful")]
167167
public static partial void LogHealthCheckSuccessful(this ILogger logger);
168168

169169
[LoggerMessage(

src/Deveel.Messaging.Connector.Firebase/Messaging/FirebasePushConnector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ public FirebasePushConnector(ConnectionSettings connectionSettings, IFirebaseSer
6363
/// <inheritdoc/>
6464
protected override async ValueTask InitializeConnectorAsync(CancellationToken cancellationToken)
6565
{
66-
using var loggerScope = Logger.BeginScope("ProjectId={ProjectId}", new { ProjectId = _projectId });
67-
6866
// Perform authentication first
6967
var result = await AuthenticateAsync(cancellationToken);
7068
if (!result.Successful)
@@ -82,6 +80,8 @@ protected override async ValueTask InitializeConnectorAsync(CancellationToken ca
8280
throw new MessagingException(ConnectorErrorCodes.InitializationError, "ProjectId is required");
8381
}
8482

83+
using var loggerScope = Logger.BeginScope("ProjectId={ProjectId}", _projectId);
84+
8585
// Get the service account key from the authenticated credential
8686
if (AuthenticationCredential?.AuthenticationType == AuthenticationType.Certificate)
8787
{

src/Deveel.Messaging.Connector.Telegram/Messaging/LoggerExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal static partial class LoggerExtensions
1919
public static partial void LogBotInitialized(this ILogger logger, string? botUsername, long botId);
2020

2121
[LoggerMessage(
22-
EventId = TelegramLoggerEventId.BotConnectionTestSuccessfull,
22+
EventId = TelegramLoggerEventId.BotConnectionTestSuccessful,
2323
Level = LogLevel.Information,
2424
Message = "Bot connection test successful: @{BotUsername} ({BotId})")]
2525
public static partial void LogBotConnectionTestSuccessful(this ILogger logger, string? botUsername, long botId);
@@ -77,7 +77,7 @@ internal static partial class LoggerExtensions
7777
Level = LogLevel.Warning,
7878
Message = "Failed to remove webhook during shutdown")]
7979
public static partial void LogWebhookRemovalFailed(this ILogger logger, Exception exception);
80-
80+
8181
[LoggerMessage(
8282
EventId = 6002,
8383
Level = LogLevel.Warning,

src/Deveel.Messaging.Connector.Telegram/Messaging/TelegramLoggerEventId.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ public static class TelegramLoggerEventId
66

77
public const int BotInitialized = BaseId + 1002;
88

9-
public const int BotConnectionTestSuccessfull = BaseId + 2001;
9+
public const int BotConnectionTestSuccessful = BaseId + 2001;
1010
}

0 commit comments

Comments
 (0)