feat(logging): add info-level logging for applied configuration changes#1021
Open
tdabasinskas wants to merge 1 commit into
Open
Conversation
When safe-settings applies changes to repositories, users need visibility into what actions are being taken without enabling debug logging. This change adds informational log messages when changes are applied, while keeping detailed diffs at debug level. The info messages indicate: - Which plugin is applying changes (branches, repository settings, topics, labels, etc.) - Which repository is being modified - That detailed diffs are available at debug level This improves operational visibility and makes it easier to track configuration changes in production environments without overwhelming logs with detailed diffs.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds user-visible (info-level) logging when safe-settings actually applies configuration changes, improving traceability at default log levels while keeping potentially sensitive diffs at debug level. This addresses the lack of visibility called out in #451.
Changes:
- Emit one info-level log line when
Diffableplugins apply changes (non-nop), pointing to debug logs for the full diff. - Emit an info-level log line when branch protection changes are applied (non-nop).
- Emit separate info-level log lines when repository settings and topic updates are applied (non-nop), and fix two debug logs that previously printed
[object Object].
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lib/plugins/diffable.js | Adds info-level “Applying changes…” log for non-nop runs when changes are detected. |
| lib/plugins/branches.js | Adds info-level log when branch protection changes are about to be applied (non-nop). |
| lib/plugins/repository.js | Adds info-level logs for repository settings/topics apply; fixes debug logs to stringify objects properly. |
| test/unit/lib/plugins/labels.test.js | Updates logger stub; asserts info log is emitted when applying label changes. |
| test/unit/lib/plugins/branches.test.js | Updates logger stub; adds assertion that branch-protection apply is logged at info. |
| test/unit/lib/plugins/repository.test.js | Updates logger stub; asserts info logs for repository settings and topics; removes it.only. |
| test/unit/lib/plugins/rulesets.test.js | Updates logger stub to include info. |
| test/unit/lib/plugins/environments.test.js | Updates logger stub(s) to include info. |
| test/unit/lib/plugins/variables.test.js | Updates logger stub to include info. |
| test/unit/lib/plugins/teams.test.js | Updates logger stub to include info. |
| test/unit/lib/plugins/custom_properties.test.js | Updates logger stub to include info. |
| test/unit/lib/plugins/collaborators.test.js | Updates logger stub to include info. |
| test/unit/lib/plugins/autolinks.test.js | Updates logger stub to include info. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #451.
When safe-settings applies changes (non-dry-run), nothing is visible above debug level: the diff computation, the "there are changes" decision, and the API call results are all
log.debug. At the default log level a sync that rewrites branch protection across an org produces no trace of what it changed. HagegeR and tylerohlsen asked for exactly this in #451.This PR adds one info-level line per applied change, in the three places changes are actually applied:
lib/plugins/diffable.js(covers labels, teams, collaborators, autolinks, variables, rulesets, and the other diffable plugins):Applying <Plugin> changes to <owner>/<repo>lib/plugins/branches.js:Applying branch protection changes to <branch> branch of <owner>/<repo>lib/plugins/repository.js: separate lines for repository settings and topic changesEach line points at the debug level for the full diff rather than embedding it. That's deliberate: diffs can contain config values (e.g. Actions variables), and per the review discussion on #1018 those shouldn't land in info-level logs. The full diffs were already logged at debug; that behavior is unchanged. Dry-run (nop) output is also unchanged.
Also fixes two debug statements in
repository.jsthat interpolated objects into template strings and printedResult of comparing repo for changes = [object Object](the bug @HagegeR pointed out in the issue comments, in its current location).