Skip to content

Commit

Permalink
fix: ddapmtest-agent-fmt logging (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettlangdon authored Jan 28, 2022
1 parent 7d814c3 commit 5773155
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ddapm_test_agent/fmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ def main(args: Optional[List[str]] = None) -> None:

# Find all json files
resolved_files = _resolve_files(parsed_args.files)
log.info("Found {} snapshot files to process", (len(resolved_files),))
log.info("Found %d snapshot files to process", len(resolved_files))

has_errors = False
for fname in resolved_files:
log.debug("Checking snapshot file {!r}", (fname,))
log.debug("Checking snapshot file %r", fname)
try:
# Read the original file data
with open(fname, "r") as fp:
Expand All @@ -95,19 +95,19 @@ def main(args: Optional[List[str]] = None) -> None:

# Only do anything if something changed
if formatted != original:
log.debug("Snapshot file {!r} has changes", (fname,))
log.debug("Snapshot file %r has changes", fname)
if parsed_args.check:
# If we are in check mode and we changed the content, error
log.error("Snapshot file {!r} would be reformatted!", (fname,))
log.error("Snapshot file %r would be reformatted!", fname)
has_errors = True
else:
# Rewrite the original file with the new formatted version
with open(fname, "w") as fp:
fp.write(formatted)
log.info("Snapshot file {!r} was formatted", fname)
log.info("Snapshot file %r was formatted", fname)

except Exception:
log.exception("Error processing file {!r}: {}", (fname,))
log.error("Error processing file %r", fname)
has_errors = True

if has_errors:
Expand Down
4 changes: 4 additions & 0 deletions releasenotes/notes/fix-fmt-logging-6a323fd8d5d4eb28.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
Fix log messages in ``ddapm-test-agent-fmt``.

0 comments on commit 5773155

Please sign in to comment.