mirror of https://github.com/Squidex/squidex.git
Browse Source
* Add source-generated logging methods * Validate generated logging changes * Centralize logger messages per project * Remove redundant partial modifier after logging refactor * Extract DomainObject log message to centralized LogMessages * Centralize remaining ILogger log statements in infrastructure and web * Extend [LoggerMessage] source generation to all projects using ILogger * fix: enable logger in migrator tests * fix: enable fake loggers in entities warning-log tests --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>master
committed by
GitHub
44 changed files with 382 additions and 72 deletions
@ -0,0 +1,19 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace Squidex.Extensions; |
|||
|
|||
internal static partial class LogMessages |
|||
{ |
|||
[LoggerMessage(Level = LogLevel.Warning, Message = "Kafka error with {code} and {reason}.")] |
|||
public static partial void LogKafkaError(ILogger logger, object code, string reason); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to enrich asset.")] |
|||
public static partial void LogFailedToEnrichAsset(ILogger logger, Exception exception); |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace Squidex.Infrastructure.Counts; |
|||
|
|||
internal static partial class LogMessages |
|||
{ |
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to update count for collection {collection}.")] |
|||
public static partial void LogFailedToUpdateCount(ILogger logger, string collection, Exception exception); |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace Squidex.Domain.Apps.Core; |
|||
|
|||
internal static partial class LogMessages |
|||
{ |
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to create rule job.")] |
|||
public static partial void LogFailedToCreateRuleJob(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to create rule jobs from trigger.")] |
|||
public static partial void LogFailedToCreateRuleJobsFromTrigger(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to create rule jobs from event.")] |
|||
public static partial void LogFailedToCreateRuleJobsFromEvent(ILogger logger, Exception exception); |
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Microsoft.Extensions.Logging; |
|||
using Squidex.Infrastructure; |
|||
|
|||
namespace Squidex.Domain.Apps.Entities; |
|||
|
|||
internal static partial class LogMessages |
|||
{ |
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to register user in notifo: {details}.")] |
|||
public static partial void LogFailedToRegisterUserInNotifoWithDetails(ILogger logger, string details, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to register user in notifo.")] |
|||
public static partial void LogFailedToRegisterUserInNotifo(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to push user to notifo: {details}.")] |
|||
public static partial void LogFailedToPushUserToNotifoWithDetails(ILogger logger, string details, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to push user to notifo.")] |
|||
public static partial void LogFailedToPushUserToNotifo(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to delete asset recursively.")] |
|||
public static partial void LogFailedToDeleteAssetRecursively(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Information, Message = "Backup with job id {backupId} with from URL '{url}' started.")] |
|||
public static partial void LogRestoreJobStarted(ILogger logger, DomainId backupId, Uri url); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Information, Message = "Backup with job id {backupId} from URL '{url}' completed.")] |
|||
public static partial void LogRestoreJobCompleted(ILogger logger, DomainId backupId, Uri url); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Backup with job id {backupId} from URL '{url}' failed.")] |
|||
public static partial void LogRestoreJobFailed(ILogger logger, DomainId backupId, Uri url, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to clean up restore.")] |
|||
public static partial void LogFailedToCleanUpRestore(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to handle yjs event.")] |
|||
public static partial void LogFailedToHandleYjsEvent(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Warning, Message = "Cannot send email to {email}: No email subject configured for template {template}.")] |
|||
public static partial void LogNoEmailSubjectConfigured(ILogger logger, string email, string template); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Warning, Message = "Cannot send email to {email}: No email body configured for template {template}.")] |
|||
public static partial void LogNoEmailBodyConfigured(ILogger logger, string email, string template); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to send notification to {email}.")] |
|||
public static partial void LogFailedToSendNotification(ILogger logger, string email, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to query scheduled status changes-")] |
|||
public static partial void LogFailedToQueryScheduledStatusChanges(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to execute scheduled status change for content '{contentId}'.")] |
|||
public static partial void LogFailedToExecuteScheduledStatusChange(ILogger logger, DomainId contentId, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to resolve field {field}.")] |
|||
public static partial void LogFailedToResolveField(ILogger logger, string field, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to resolve execute query.")] |
|||
public static partial void LogFailedToResolveQuery(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Warning, Message = "Failed to invite user: Assigner {assignerId} not found.")] |
|||
public static partial void LogInvitationAssignerNotFound(ILogger logger, RefToken assignerId); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Warning, Message = "Failed to invite user: Assignee {assigneeId} not found.")] |
|||
public static partial void LogInvitationAssigneeNotFound(ILogger logger, string assigneeId); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Warning, Message = "Removed unfinished jobs for owner {ownerId} after start.")] |
|||
public static partial void LogRemovedUnfinishedJobs(ILogger logger, DomainId ownerId); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Information, Message = "Clearing jobs for owner {ownerId}.")] |
|||
public static partial void LogClearingJobs(ILogger logger, DomainId ownerId); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Information, Message = "Starting new backup with backup id '{backupId}' for owner {ownerId}.")] |
|||
public static partial void LogStartingJob(ILogger logger, DomainId backupId, DomainId ownerId); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to run job with ID {jobId}.")] |
|||
public static partial void LogFailedToRunJob(ILogger logger, DomainId jobId, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Information, Message = "Adding rule job for Rule(trigger={ruleTrigger})")] |
|||
public static partial void LogAddingRuleJob(ILogger logger, string ruleTrigger); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Warning, Message = "Failed to run rule with ID {ruleId}, continue with next job.")] |
|||
public static partial void LogFailedToRunRule(ILogger logger, DomainId? ruleId, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to execute search from source {source} with query '{query}'.")] |
|||
public static partial void LogFailedToExecuteSearch(ILogger logger, string source, string query, Exception exception); |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace Squidex.Domain.Users; |
|||
|
|||
internal static partial class LogMessages |
|||
{ |
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to cleanup user after creation failed.")] |
|||
public static partial void LogFailedToCleanupUser(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Identity operation failed: {errorMessage}.")] |
|||
public static partial void LogIdentityOperationFailed(ILogger logger, string errorMessage); |
|||
} |
|||
@ -0,0 +1,64 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace Squidex.Infrastructure; |
|||
|
|||
internal static partial class LogMessages |
|||
{ |
|||
[LoggerMessage(Level = LogLevel.Debug, Message = "Command {command} with ID {id} started.")] |
|||
public static partial void LogCommandStarted(ILogger logger, Type command, DomainId id); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Information, Message = "Command {command} with ID {id} succeeded.")] |
|||
public static partial void LogCommandSucceeded(ILogger logger, Type command, DomainId id); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Information, Message = "Command {command} with ID {id} completed after {time}ms.")] |
|||
public static partial void LogCommandCompleted(ILogger logger, Type command, DomainId id, long time); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Command {command} with ID {id} failed.")] |
|||
public static partial void LogCommandFailed(ILogger logger, Type command, DomainId id, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Critical, Message = "Command {command} with ID {id} not handled.")] |
|||
public static partial void LogCommandNotHandled(ILogger logger, Type command, DomainId id); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Critical, Message = "Failed to complete consumer.")] |
|||
public static partial void LogFailedToCompleteConsumer(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to handle event.")] |
|||
public static partial void LogFailedToHandleEvent(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Critical, Message = "Failed to update consumer {consumer} at position {position} from {caller}.")] |
|||
public static partial void LogFailedToUpdateConsumer(ILogger logger, string consumer, string? position, string? caller, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Debug, Message = "Event consumer {consumer} reset started")] |
|||
public static partial void LogEventConsumerResetStarted(ILogger logger, string consumer); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Debug, Message = "Event consumer {consumer} reset completed after {time}ms.")] |
|||
public static partial void LogEventConsumerResetCompleted(ILogger logger, string consumer, long time); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Information, Message = "Migration {migration} started.")] |
|||
public static partial void LogMigrationStarted(ILogger logger, string migration); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Information, Message = "Migration {migration} completed after {time}ms.")] |
|||
public static partial void LogMigrationCompleted(ILogger logger, string migration, long time); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Critical, Message = "Migration {migration} failed.")] |
|||
public static partial void LogMigrationFailed(ILogger logger, string migration, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Information, Message = "Could not acquire lock to start migrating. Trying again in {time}ms.")] |
|||
public static partial void LogMigrationLockRetry(ILogger logger, int time); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to track usage in background.")] |
|||
public static partial void LogTrackUsageFailed(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to repair snapshot for domain object of type {type} with ID {id}.")] |
|||
public static partial void LogFailedToRepairDomainObjectSnapshot(ILogger logger, Type type, DomainId id, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Warning, Message = "Found corrupt domain object of type {type} with ID {id}.")] |
|||
public static partial void LogFoundCorruptDomainObject(ILogger logger, Type type, DomainId id, Exception exception); |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Microsoft.Extensions.Logging; |
|||
using Squidex.Infrastructure; |
|||
|
|||
namespace Squidex.Web; |
|||
|
|||
internal static partial class LogMessages |
|||
{ |
|||
[LoggerMessage(Level = LogLevel.Error, Message = "An unexpected exception has occurred.")] |
|||
public static partial void LogUnexpectedException(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Critical, Message = "Failed to send result.")] |
|||
public static partial void LogFailedToSendResult(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Warning, Message = "Cannot find app with the given name {name}.")] |
|||
public static partial void LogCannotFindAppByName(ILogger logger, string name); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Warning, Message = "Authenticated user has no permission to access the app {name} with ID {id}.")] |
|||
public static partial void LogNoPermissionToAccessApp(ILogger logger, DomainId id, string name); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Warning, Message = "Cannot find team with the given id {id}.")] |
|||
public static partial void LogCannotFindTeamById(ILogger logger, string id); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Warning, Message = "Authenticated user has no permission to access the team with ID {id}.")] |
|||
public static partial void LogNoPermissionToAccessTeam(ILogger logger, DomainId id); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Error while handling api key.")] |
|||
public static partial void LogErrorHandlingApiKey(ILogger logger, Exception exception); |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace Squidex; |
|||
|
|||
internal static partial class LogMessages |
|||
{ |
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to create administrator.")] |
|||
public static partial void LogFailedToCreateAdministrator(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to return users, returning empty results.")] |
|||
public static partial void LogFailedToReturnUsers(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to return user, returning empty results.")] |
|||
public static partial void LogFailedToReturnUser(ILogger logger, Exception exception); |
|||
|
|||
[LoggerMessage(Level = LogLevel.Error, Message = "Failed to return user picture, returning fallback image.")] |
|||
public static partial void LogFailedToReturnUserPicture(ILogger logger, Exception exception); |
|||
} |
|||
Loading…
Reference in new issue