Closed
Description
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:
import logging
from click import pass_context
from click_extra import extra_command, extra_basic_config, verbosity_option
extra_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",)
def cli(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.