Support for custom fields in juturna logging#185
Merged
Conversation
GaijinKa
reviewed
Jun 16, 2026
GaijinKa
left a comment
Member
There was a problem hiding this comment.
The PR looks good to me.
I've only raised a couple of concerns about _REGISTRY and a convention lock-in that could become problematic if it remains undocumented and we later decide to change that convention. No changes requested, just a comment
… allowed in extras
Member
|
You can merge this PR! As a side note, I think this PR should be flagged as breaking, since the CLI parameters have changed. However, we already have several breaking changes in the stack for the next release, so the version will be bumped anyway without amend any commit |
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.
Description
This PR introduces a number of changes to the logging facility in juturna.
1. Add formatters to the juturna logger
Users can now add custom formatters without the need to create a handler. The formatter will be added to the current handler.
2. New juturna formatter
A new type of formatter was added to juturna, called
JuturnaFormatter. In combination with a new filter calledJuturnaPipelineFilter, this allows to add custom fields to the log records directly in the pipeline configuration file.The juturna formatter can be used like any other formatter:
A juturna formatter accepts non-standard fields. If those fields are not available, their name will be printed in the log output:
Custom fields can be defined on a pipeline level, directly in the configuration file:
3. Log configuration file for juturna service
The juturna service CLI was changed so that, instead of individual parameters for the logger, it now accepts a fully fledged log configuration file. This allows to achieve the very same granularity offered by the low-level logging APIs in juturna.
An example of configuration file for the logs follows:
{ "version": 1, "disable_existing_loggers": true, "formatters": { "standard": { "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s" }, "json": { "()": "juturna.utils.log_utils.JsonFormatter" }, "juturna": { "format": "%(env)s | %(name)s | %(message)s", "()": "juturna.utils.log_utils.JuturnaFormatter" } }, "handlers": { "console": { "class": "logging.StreamHandler", "level": "DEBUG", "formatter": "juturna", "stream": "ext://sys.stdout", "filters": [ "custom" ] }, "file_stream": { "class": "logging.handlers.RotatingFileHandler", "level": "DEBUG", "formatter": "json", "filename": "/tmp/juturna_log.json", "maxBytes": 10485760, "backupCount": 20, "encoding": "utf8" }, "service": { "class": "logging.StreamHandler", "level": "DEBUG", "formatter": "standard", "stream": "ext://sys.stdout" } }, "filters": { "custom": { "()": "juturna.utils.log_utils.JuturnaPipelineFilter" } }, "root": { "level": "NOTSET", "handlers": [ "console" ], "propogate": "yes" }, "loggers": { "jt": { "handlers": [ "console", "file_stream" ] }, "jt.service": { "handlers": ["service"] } } }4.
jt.utils.log_utilsnow exposes formatters and filtersThe
jt.logmodule now exposes some formatters and filters that are shipped with juturna, so that their classes can be linked in the log configuration files. These are:juturna.utils.log_utils.ColoredFormatterjuturna.utils.log_utils.JsonFormatterjuturna.utils.log_utils.JuturnaFormatterjuturna.utils.log_utils.JuturnaPipelineFilterPR type
Select all the labels that apply to this PR.