Skip to content

V27/logging guards#916

Merged
KevinJump merged 6 commits intov17/mainfrom
v27/logging-guards
Mar 24, 2026
Merged

V27/logging guards#916
KevinJump merged 6 commits intov17/mainfrom
v27/logging-guards

Conversation

@KevinJump
Copy link
Copy Markdown
Owner

Adds IsEnabled checks to all LogInformation, LogDebug and LogTrace calls. in theory this is a performance improvement, because it stops the code doing any string allocations / manipulation that are not needed.

(https://learn.microsoft.com/en-gb/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

(we might move to source-generated logging at a later date)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds explicit ILogger.IsEnabled(LogLevel.X) guards around many LogDebug/LogTrace/LogInformation calls across uSync Core and BackOffice to avoid unnecessary work when those levels are disabled (per CA1873 guidance).

Changes:

  • Wrapped many LogDebug, LogTrace, and LogInformation calls with IsEnabled(...) checks across serializers, handlers, services, and notifications.
  • Minor logging behavior adjustments in a few places (some log removals and some log level changes).

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
uSync.Core/Serialization/SyncSerializerRoot.cs Adds IsEnabled(Debug/Trace) guards around serializer root debug/trace logs; one delete log was removed.
uSync.Core/Serialization/SyncContainerSerializerBase.cs Guards debug logs in container delete handling and parent discovery flow.
uSync.Core/Serialization/Serializers/TemplateSerializer.cs Guards debug logs during template import/content resolution and save; contains a log-message typo.
uSync.Core/Serialization/Serializers/LanguageSerializer.cs Removes an unguarded debug log in second pass.
uSync.Core/Serialization/Serializers/DictionaryItemSerializer.cs Adds debug guard for “force key sync”; changes key-mismatch log from Information to Warning.
uSync.Core/Serialization/Serializers/DataTypeSerializer.cs Guards debug logs in delete/config handling; retains a stray “)” in a message.
uSync.Core/Serialization/Serializers/ContentTypeSerializer.cs Guards debug log for alias cache timing and other debug statements.
uSync.Core/Serialization/Serializers/ContentTypeBaseSerializer.cs Guards many debug/info logs; retains inconsistent structured logging placeholder {aliaS} and a message typo.
uSync.Core/Serialization/Serializers/ContentSerializerBase.cs Guards debug/trace logs in content deserialization; changes regex parse log from Debug to Warning.
uSync.Core/Mapping/SyncBlockMapperBase.cs Guards debug logs for import/export block mapping.
uSync.Core/Mapping/Mappers/ImagePathMapper.cs Simplifies debug logging for media folder setting (now logs “(Blank)” when empty).
uSync.Core/Documents/SyncDocumentUrlCleaner.cs Guards debug log when cleaning document URLs.
uSync.Core/DataTypes/DataTypeSerializers/RichTextEditorMigratingSerializer.cs Guards debug logs during RTE config migration.
uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs Guards debug/trace logs during import, clean, and reporting flows.
uSync.BackOffice/SyncHandlers/SyncHandlerFactory.cs Guards trace log when excluding disabled handlers.
uSync.BackOffice/SyncHandlers/SyncHandlerContainerBase.cs Guards debug logs when processing container cleanup/changes.
uSync.BackOffice/SyncHandlers/SyncHandlerBase.cs Guards debug/info logs for clean/delete operations.
uSync.BackOffice/SyncHandlers/Handlers/LanguageHandler.cs Guards debug logs during language cleanup.
uSync.BackOffice/SyncHandlers/Handlers/ContentHandlerBase.cs Guards debug logs for include/exclude path/doc-type filtering and cleanup mode.
uSync.BackOffice/Services/SyncService_Single.cs Guards debug log emitted after partial import.
uSync.BackOffice/Services/SyncService.cs Guards info logs for startup import/export summaries and trigger actions.
uSync.BackOffice/Services/SyncFileService.cs Guards debug logs when saving files.
uSync.BackOffice/Services/SyncActionService.cs Guards info logs for start/finish process reporting.
uSync.BackOffice/Notifications/uSyncApplicationStartingHandler.cs Guards info logs and switches one interpolated log to structured placeholders.
uSync.BackOffice/Notifications/SyncScopedNotificationPublisher.cs Guards debug logs around scoped notification publishing.
uSync.BackOffice/Boot/FirstBootMigration.cs Guards info logs during first-boot import migration.
uSync.AutoTemplates/TemplateWatcher.cs Guards info log when checking template files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread uSync.Core/Serialization/Serializers/DictionaryItemSerializer.cs
Comment thread uSync.Core/Serialization/Serializers/ContentTypeBaseSerializer.cs Outdated
Comment thread uSync.Core/Serialization/Serializers/TemplateSerializer.cs Outdated
Comment thread uSync.Core/Serialization/Serializers/DataTypeSerializer.cs Outdated
Comment thread uSync.Core/Serialization/Serializers/ContentTypeBaseSerializer.cs Outdated
Comment thread uSync.Core/Serialization/Serializers/ContentSerializerBase.cs
Comment thread uSync.Core/Serialization/SyncSerializerRoot.cs
KevinJump and others added 4 commits March 24, 2026 11:42
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@KevinJump KevinJump merged commit 64a1ce2 into v17/main Mar 24, 2026
4 checks passed
@KevinJump KevinJump deleted the v27/logging-guards branch March 24, 2026 11:58
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