Add structured logging support - #2029
Conversation
Replace AYON logger and standard python logger with structlog, allowing proper structured logging and rudimentary support of log aggregation.
There was a problem hiding this comment.
Pull request overview
Adds structured logging to ayon-core by introducing a structlog-based logging configuration (with optional Vector HTTP forwarding) and updating key entry points to rely on root-logger propagation rather than the legacy AYON logger handler setup.
Changes:
- Add
structlogandrichdependencies (and lockfile updates) to support structured console rendering and JSON output. - Introduce
configure_logger()and Vector HTTP forwarding (async viaQueueListener) inclient/ayon_core/lib/log.py, and adjust the legacyLoggerto delegate to structlog when configured. - Update CLI and publishing log handler wiring to rely on propagation into the root logger.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Bumps local version and adds locked deps for structlog/rich (+ transitive deps). |
pyproject.toml |
Adds runtime deps and adjusts pytest testpaths; adds tool.ty extra-paths. |
client/ayon_core/pipeline/publish/logic.py |
Removes explicit AYON root handler wiring; relies on propagation to root. |
client/ayon_core/lib/log.py |
Adds structlog configuration, Vector HTTP handler + queue pipeline, and structlog delegation in Logger.get_logger. |
client/ayon_core/lib/__init__.py |
Exports configure_logger from ayon_core.lib. |
client/ayon_core/cli.py |
Initializes logging via configure_logger() and replaces some prints with structured logs. |
client/ayon_core/addon/base.py |
Adjusts addon init log message text. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @contextmanager | ||
| def _log_manager(self, plugin: PluginType): | ||
| root = logging.getLogger() | ||
| ayon_root = Logger.get_root_logger() |
There was a problem hiding this comment.
Why was this removed? We added this so we can see logs in publish report viewer.
There was a problem hiding this comment.
good catch, this is misfire. I tried to figure out double-logging. In any way - if we start using structlog, we could rewrite the publisher loging as another sink with it's own processors. I'll revert the changes.
| "Pillow ==9.5.0", | ||
| "structlog>=26.1.0", | ||
| "rich>=15.0.0", | ||
| "requests>=2.32.5", |
There was a problem hiding this comment.
Requests is defined by launcher, how usefull will this be?
There was a problem hiding this comment.
when you run tests for example, they work with the .venv defined by the addon, not the launcher venv.
| super().close() | ||
|
|
||
|
|
||
| def configure_logger() -> None: |
There was a problem hiding this comment.
Why do we need to call this explicitly? Not all processes are executed through cli. Most of processes are not executed through cli.
There was a problem hiding this comment.
you need to configure the logger somewhere. It needs some entrypoint. The goal is to find out all the entrypoints and add this there.
| # Delegate to structlog when configured so records share the same | ||
| # processors (e.g. 'site_id', timestamps) as the rest of the app. | ||
| if structlog.is_configured(): | ||
| return structlog.get_logger(name or "__main__") |
There was a problem hiding this comment.
| return structlog.get_logger(name or "__main__") | |
| return structlog.get_logger(name) |
There was a problem hiding this comment.
this followed the same logic already in place but even there "__main__" shouldn't happen.
|
|
||
| # Delegate to structlog when configured so records share the same | ||
| # processors (e.g. 'site_id', timestamps) as the rest of the app. | ||
| if structlog.is_configured(): |
There was a problem hiding this comment.
This does completelly skip the existing AYON logic. I just don't understand?
There was a problem hiding this comment.
yes, it use structlog configured logger as root logger. Eventually we can completely remove ayon_core.lib.Logger
Changelog Description
Add structured logging support. For description see ynput/ayon-launcher#326 (that is required by this)
Additional Notes
There are still some issues (linting, code placement, Vector related code) but let's kickstart some discussion.