Summary
gateway.log is not attached on the normal hermes gateway run startup path because logging is initialized in CLI mode first, and the later gateway-mode initialization is skipped by the global idempotency guard.
Affected version
Observed on commit 4eecaf06.
Reproduction
- Start Hermes through the normal CLI entrypoint:
- Generate some gateway activity.
- Inspect
~/.hermes/logs/.
Actual behavior
agent.log and errors.log are active.
gateway.log exists but remains empty, or is never attached as an active handler.
- Gateway logger output still lands in
agent.log.
Expected behavior
gateway.log should be attached and should receive records from gateway.* loggers during hermes gateway run.
Root cause
The CLI entrypoint initializes logging in CLI mode very early:
hermes_cli/main.py calls setup_logging(mode="cli")
Later, gateway startup tries to initialize gateway logging:
gateway/run.py calls setup_logging(..., mode="gateway")
But hermes_logging.setup_logging() returns early once _logging_initialized is already True, so the gateway-specific handler is never added.
That means the code path that creates the filtered gateway.log handler is skipped on the normal CLI -> gateway startup flow.
Minimal reproduction at the Python level
import hermes_logging
hermes_logging.setup_logging(mode="cli")
hermes_logging.setup_logging(mode="gateway")
Result: only agent.log and errors.log are attached.
If setup_logging(mode="gateway") is called first, gateway.log is created correctly.
Suggested fix
When setup_logging() is called again with mode="gateway", it should still ensure that the gateway.log handler exists instead of returning immediately.
One approach would be:
- keep the function idempotent for existing handlers
- but on a later
mode="gateway" call, add the missing gateway.log handler if it has not been attached yet
Regression test suggestion
Add a test that covers this exact sequence:
setup_logging(mode="cli")
setup_logging(mode="gateway")
- assert that
gateway.log handler exists and receives gateway.* records
Summary
gateway.logis not attached on the normalhermes gateway runstartup path because logging is initialized in CLI mode first, and the later gateway-mode initialization is skipped by the global idempotency guard.Affected version
Observed on commit
4eecaf06.Reproduction
~/.hermes/logs/.Actual behavior
agent.loganderrors.logare active.gateway.logexists but remains empty, or is never attached as an active handler.agent.log.Expected behavior
gateway.logshould be attached and should receive records fromgateway.*loggers duringhermes gateway run.Root cause
The CLI entrypoint initializes logging in CLI mode very early:
hermes_cli/main.pycallssetup_logging(mode="cli")Later, gateway startup tries to initialize gateway logging:
gateway/run.pycallssetup_logging(..., mode="gateway")But
hermes_logging.setup_logging()returns early once_logging_initializedis alreadyTrue, so the gateway-specific handler is never added.That means the code path that creates the filtered
gateway.loghandler is skipped on the normal CLI -> gateway startup flow.Minimal reproduction at the Python level
Result: only
agent.loganderrors.logare attached.If
setup_logging(mode="gateway")is called first,gateway.logis created correctly.Suggested fix
When
setup_logging()is called again withmode="gateway", it should still ensure that thegateway.loghandler exists instead of returning immediately.One approach would be:
mode="gateway"call, add the missinggateway.loghandler if it has not been attached yetRegression test suggestion
Add a test that covers this exact sequence:
setup_logging(mode="cli")setup_logging(mode="gateway")gateway.loghandler exists and receivesgateway.*records