Feature: Log to file for GraphServer CLI#248
Open
griffinmilsap wants to merge 6 commits into
Open
Conversation
GraphServer CLIGraphServer CLI
Replaced inferring format from pre-exsiting logger handlers
log_level<WARNING goes to stdout and log_level>=WARNING goes to stderr
KonradPilch
approved these changes
Jun 2, 2026
Contributor
KonradPilch
left a comment
There was a problem hiding this comment.
I like what you've done. I have a few suggestions which I have added as commits to this branch. Please look through them. My changes based on my review:
- Wired
log_fileintorun_commandto avoid anAttributeError. - Lifecycle management of logging handlers we create.
- Defined a standard logging formatter in
logconfig.pythat is accessed viacreate_ezmsg_log_formatter(). - Split logs between stdout and stderr based on the log level (for when other processes own the Graph Service).
| parser.add_argument("--address", help="Address for GraphServer", default=None) | ||
|
|
||
|
|
||
| def add_log_file_argument(parser: argparse.ArgumentParser) -> None: |
Contributor
There was a problem hiding this comment.
Need to plumb this into run_command() too.
| and getattr(handler, "baseFilename", None) == str(log_path) | ||
| for handler in logger.handlers | ||
| ): | ||
| formatter = next( |
Contributor
There was a problem hiding this comment.
We can just define the standard ezmsg formatter and use that.
| ), | ||
| None, | ||
| ) | ||
| handler = logging.FileHandler(log_path, encoding="utf-8") |
Contributor
There was a problem hiding this comment.
we should probably deal with lifecycle management here, so that we don't leave open handlers we created.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #246
Summary
Add file logging for the
ezmsg start/ezmsg serveservice envelope.This change adds
--log-filesupport to both commands, passes the option through fromstartto the spawnedservesubprocess, and otherwise falls back toEZMSG_LOG_FILEor a default per-run log path under a platform-appropriate ezmsg data directory. Default logs are organized by GraphServer port and use a timestamped filename for each execution.Scope
This intentionally stays narrow and only affects the
start/serveworkflow. It does not attempt to define broader logging behavior yet forez.run,GraphRunner, subprocess/session aggregation, or remote clients.Testing
serve --log-filestartpasses--log-filethrough toserve