diff --git a/src/fastcs/launch.py b/src/fastcs/launch.py index eec14114..7165fbf8 100644 --- a/src/fastcs/launch.py +++ b/src/fastcs/launch.py @@ -105,10 +105,7 @@ def run( help=f"A yaml file matching the {controller_class.__name__} schema" ), ], - log_level: Annotated[ - Optional[LogLevel], # noqa: UP045 - typer.Option(), - ] = None, + log_level: Annotated[LogLevel, typer.Option()] = LogLevel.INFO, graylog_endpoint: Annotated[ Optional[GraylogEndpoint], # noqa: UP045 typer.Option( diff --git a/src/fastcs/logging/__init__.py b/src/fastcs/logging/__init__.py index 9c60ff3a..ba11b087 100644 --- a/src/fastcs/logging/__init__.py +++ b/src/fastcs/logging/__init__.py @@ -16,7 +16,7 @@ drivers. This logger uses ``loguru`` as underlying logging library, which enables much simpler configuration as well as structured logging. -Keyword arguments to log statments will be attached as extra fields on the log record. +Keyword arguments to log statements will be attached as extra fields on the log record. These fields are displayed separately in the console output and can used for filtering and metrics in graylog. @@ -70,7 +70,7 @@ def bind_logger(logger_name: str) -> Logger: def configure_logging( - level: LogLevel | None = None, + level: LogLevel = LogLevel.INFO, graylog_endpoint: GraylogEndpoint | None = None, graylog_static_fields: GraylogStaticFields | None = None, graylog_env_fields: GraylogEnvFields | None = None, @@ -95,7 +95,7 @@ def configure_logging( # Configure logger with defaults - INFO level and disabled -configure_logging() +_configure_logger(logger) class _StdLoggingInterceptHandler(logging.Handler): diff --git a/src/fastcs/logging/_logging.py b/src/fastcs/logging/_logging.py index 1114a6db..3dc2ba2f 100644 --- a/src/fastcs/logging/_logging.py +++ b/src/fastcs/logging/_logging.py @@ -87,6 +87,9 @@ def format_record(record) -> str: else: extras = "" + # Escape braces so Loguru doesn't parse them as format placeholders + extras = extras.replace("{", "{{").replace("}", "}}") + return f"""\ [{time} {record["level"].name[0]}] \ {record["message"]:<80} \