Skip to content

Add support for JSON logging - #139

Open
TilBlechschmidt wants to merge 3 commits into
postfinance:mainfrom
TilBlechschmidt:feature/json-logging
Open

Add support for JSON logging#139
TilBlechschmidt wants to merge 3 commits into
postfinance:mainfrom
TilBlechschmidt:feature/json-logging

Conversation

@TilBlechschmidt

@TilBlechschmidt TilBlechschmidt commented Sep 8, 2026

Copy link
Copy Markdown

Hey 👋

Saw your talk about topf on the ContainerDays and decided to give it a go. Really cool project and thanks for publishing it!

As I want to invoke topf from another tool and would like to cleanly pass log outputs through, it would be really cool to have support for JSON logging. In this MR I gave it a shot with my arguably limited Go knowledge:

I added global --json-log and TOPF_JSON_LOG arguments which instantiate the TopfRuntime logger with the JsonHandler instead of the regular one. Additionally, I modified the render command which printed what I would consider a log message directly to stdout.

One slight annoyance is that the CLI command error handler has no access to the logger instantiated from the CLI args and thus uses the slog default handler. For the initial draft, I set the runtime logger as the global default though I can understand if that is not desirable. Let me know if you have a better idea!

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