Skip to content

Add structured logging support - #2029

Open
antirotor wants to merge 5 commits into
developfrom
feature/structured-logging
Open

Add structured logging support#2029
antirotor wants to merge 5 commits into
developfrom
feature/structured-logging

Conversation

@antirotor

Copy link
Copy Markdown
Member

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.

Replace AYON logger and standard python logger with structlog, allowing proper structured logging and rudimentary support of log aggregation.
@antirotor
antirotor requested review from BigRoy and iLLiCiTiT and a lite review from Copilot August 28, 2026 17:59
@antirotor antirotor self-assigned this Aug 28, 2026
@antirotor antirotor added the type: feature Adding something new and exciting to the product label Aug 28, 2026
@ynbot ynbot added the size/S label Aug 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 structlog and rich dependencies (and lockfile updates) to support structured console rendering and JSON output.
  • Introduce configure_logger() and Vector HTTP forwarding (async via QueueListener) in client/ayon_core/lib/log.py, and adjust the legacy Logger to 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.

Comment thread pyproject.toml
Comment thread pyproject.toml
Comment thread client/ayon_core/cli.py
Comment thread client/ayon_core/lib/log.py
Comment thread client/ayon_core/lib/log.py
@contextmanager
def _log_manager(self, plugin: PluginType):
root = logging.getLogger()
ayon_root = Logger.get_root_logger()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed? We added this so we can see logs in publish report viewer.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ynbot ynbot moved this to Review In Progress in PR reviewing Aug 31, 2026
Comment thread pyproject.toml
"Pillow ==9.5.0",
"structlog>=26.1.0",
"rich>=15.0.0",
"requests>=2.32.5",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requests is defined by launcher, how usefull will this be?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

@iLLiCiTiT iLLiCiTiT Aug 31, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to call this explicitly? Not all processes are executed through cli. Most of processes are not executed through cli.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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__")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return structlog.get_logger(name or "__main__")
return structlog.get_logger(name)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does completelly skip the existing AYON logic. I just don't understand?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it use structlog configured logger as root logger. Eventually we can completely remove ayon_core.lib.Logger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S type: feature Adding something new and exciting to the product

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

4 participants