You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My terminal outputs two logs, is there a problem where I am processing?
My intention: to format all log content in json format so that I can analyze and notify using the log collector .
Also what can I do to define the Load configuration matching foo.ini in json format as well?
demo.py:
importloggingfromclickimportpass_contextfromclick_extraimportextra_command, extra_basic_config, verbosity_optionextra_basic_config(
logger_name="app_logger",
format='{{"time": "{asctime}", "name": "{name}", "level": "{levelname}", "msg": "{message}"}}',
force=True,
level=logging.INFO,
)
@extra_command@pass_context@verbosity_option(default_logger="app_logger",)defcli(config):
logging.getLogger("app_logger").info("This is an info message from the root logger.")
output:
Load configuration matching foo.ini
{"time": "2024-06-18 10:35:50,018", "name": "app_logger", "level": "info", "msg": "This is an info message from the root logger."}
info: This is an info message from the root logger.
The text was updated successfully, but these errors were encountered:
# We have can't simply use logger.info() here as the defaults have not been
# loaded yet and the logger is stuck to its default WARNING level.
echo(message, err=True)
Still, your use-case of producing JSON for all logs is interesting. Let me dive into that. Maybe it's just a matter of setting up the right configuration.
kdeldycke
changed the title
Log output does not match what is expected
Custom JSON logger and duplicate log messages
Dec 8, 2024
Hi, when I use https://kdeldycke.github.io/click-extra/logging.html#custom-logger
My terminal outputs two logs, is there a problem where I am processing?
My intention: to format all log content in json format so that I can analyze and notify using the log collector .
Also what can I do to define the
Load configuration matching foo.ini
in json format as well?demo.py:
output:
The text was updated successfully, but these errors were encountered: