Skip to content

fix: replace print() with logger in HookRegistry#3701

Closed
memosr wants to merge 1 commit intoNousResearch:mainfrom
memosr:patch-44
Closed

fix: replace print() with logger in HookRegistry#3701
memosr wants to merge 1 commit intoNousResearch:mainfrom
memosr:patch-44

Conversation

@memosr
Copy link
Copy Markdown
Contributor

@memosr memosr commented Mar 29, 2026

HookRegistry used 7 print() calls but never imported logging. This means hook lifecycle events and errors go to stdout instead of the gateway's structured log output.

Most critically, the emit() handler error at line 151 was using print() which silently discards the full traceback. A misbehaving hook that raises an unexpected exception would show only the exception message with no stack trace, making debugging nearly impossible.

Changes:

  • Add import logging and module-level logger = logging.getLogger(name)
  • Hook skip warnings → logger.warning()
  • Hook load success → logger.info()
  • Hook load error → logger.error(exc_info=True) to capture traceback
  • Hook emit error → logger.exception() which always captures full traceback

What does this PR do?

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

How to Test

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

HookRegistry used 7 print() calls but never imported logging. This
means hook lifecycle events and errors go to stdout instead of the
gateway's structured log output.

Most critically, the emit() handler error at line 151 was using
print() which silently discards the full traceback. A misbehaving
hook that raises an unexpected exception would show only the exception
message with no stack trace, making debugging nearly impossible.

Changes:
- Add import logging and module-level logger = logging.getLogger(__name__)
- Hook skip warnings → logger.warning()
- Hook load success → logger.info()
- Hook load error → logger.error(exc_info=True) to capture traceback
- Hook emit error → logger.exception() which always captures full traceback
@memosr memosr closed this Mar 29, 2026
@memosr memosr deleted the patch-44 branch March 29, 2026 20:40
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.

1 participant