Add support for JSON logging - #139
Open
TilBlechschmidt wants to merge 3 commits into
Open
Conversation
TilBlechschmidt
force-pushed
the
feature/json-logging
branch
from
September 8, 2026 13:34
c6dbf01 to
5687378
Compare
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.
Hey 👋
Saw your talk about
topfon 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-logandTOPF_JSON_LOGarguments which instantiate theTopfRuntimelogger with the JsonHandler instead of the regular one. Additionally, I modified therendercommand 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!