refactor: migrate runtime console.log calls to structured logger (#397)

This commit is contained in:
Cameron
2026-02-26 10:16:38 -08:00
committed by GitHub
parent 673cb5100e
commit d283f837ac
10 changed files with 80 additions and 41 deletions

33
scripts/no-console.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Fail if runtime source code uses console.* directly.
# Runtime code should use createLogger() from src/logger.ts instead.
#
# Excluded:
# - CLI commands (src/cli*, onboard, setup) -- user-facing terminal output
# - Test files (*.test.ts, mock-*) -- test output
# - banner.ts -- ASCII art display
# - whatsapp/session.ts installConsoleFilters() -- intentional console interception (Baileys noise filter)
# - JSDoc examples (lines starting with ' *')
set -euo pipefail
hits=$(grep -rn 'console\.\(log\|error\|warn\|info\)(' src/ --include='*.ts' \
| grep -v '/cli' \
| grep -v '\.test\.' \
| grep -v 'mock-channel' \
| grep -v 'banner\.ts' \
| grep -v 'session\.ts.*\(originalLog\|originalError\|originalWarn\|console\.\(log\|error\|warn\) =\)' \
| grep -v 'setup\.ts' \
| grep -v 'onboard\.ts' \
| grep -v 'slack-wizard\.ts' \
| grep -v 'cron/cli\.ts' \
| grep -v ' \* ' \
|| true)
if [ -n "$hits" ]; then
echo "ERROR: Found console.* calls in runtime code (use createLogger instead):"
echo "$hits"
exit 1
fi
echo "OK: No console.* in runtime code."