Skip to content

docs: log schema validation warnings through @apify/log - #10

Merged
metalwarrior665 merged 1 commit into
masterfrom
claude/apify-log-instead-of-console-u6072g
Jul 27, 2026
Merged

docs: log schema validation warnings through @apify/log#10
metalwarrior665 merged 1 commit into
masterfrom
claude/apify-log-instead-of-console-u6072g

Conversation

@metalwarrior665

Copy link
Copy Markdown
Member

Summary

Migrated logging in pushDataWithSchemaRepair from direct console.log calls to the @apify/log library, routing all messages through a child logger at WARNING level with the pushDataWithSchemaRepair prefix.

Key Changes

  • Logging infrastructure: Replaced console.log calls with log.warning() using a child logger from @apify/log with the pushDataWithSchemaRepair prefix
  • Log level: All messages now emit at WARNING level (appropriate since they indicate push rejections and data loss)
  • Message format: Removed the hardcoded pushDataWithSchemaRepair: prefix from message strings, as it's now added by the logger itself
  • Test updates: Updated captureLogs() helper to spy on Log.prototype.warning instead of console.log, and updated all test assertions to expect messages without the prefix
  • Documentation: Updated README to show the new log format with the WARN level indicator and explain the logging behavior and configuration options

Implementation Details

  • The logger is instantiated as a module-level constant: const log = baseLog.child({ prefix: 'pushDataWithSchemaRepair' })
  • All four logging points in the source code were updated: out-of-range itemPosition warnings, round validation failure reports, give-up messages, and final push rejection messages
  • The test suite now properly validates that logs go through the correct channel (console.warn for WARNING level) and include the prefix in the rendered output
  • A new integration test verifies the complete logging behavior including level, prefix, and output channel

https://claude.ai/code/session_01WGk7vrUxB7dAt64mLKyH7J

… instead of console.log

`@apify/log` is already a required peer dependency and is what the rest of the
package uses (see src/qc-logger), but this module still wrote to console.log,
so its output ignored the Actor's log level and format and couldn't be
silenced or shipped as JSON.

Every line now goes through `log.warning`. WARNING is the right level for all
of them: each one means a push was rejected and items were altered or lost,
which is never routine, and none of them is progress reporting.

The logger is a `log.child({ prefix: 'pushDataWithSchemaRepair' })`, so the
prefix each message used to spell out by hand is now applied at render time and
composes with whatever prefix the host Actor set. Rendered output is unchanged
apart from the level tag that @apify/log adds.

Tests capture `Log.prototype.warning` rather than console.log, and a new test
lets the real logger render so the prefix and the WARNING output channel are
covered too — intercepting `Log.warning` alone would still pass if either were
wrong.

Also adds CHANGELOG.md to .prettierignore. The release workflow regenerates it
without a trailing newline, which fails `format:check` and blocks the
pre-commit hook after every release; ignoring a generated file fixes that for
good instead of until the next release.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGk7vrUxB7dAt64mLKyH7J
@metalwarrior665 metalwarrior665 changed the title Log schema validation warnings through @apify/log docs: log schema validation warnings through @apify/log Jul 27, 2026
@metalwarrior665
metalwarrior665 merged commit e6b3982 into master Jul 27, 2026
7 of 8 checks passed
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.

3 participants