Skip to content

logger: add optional format arguments to default_logger

D.J. Nolte requested to merge logger_fmt_args into main

default_logger function accepts optional arguments for the format of the console and file loggers

For example for readable indentation with longer function names (e.g. with FSI or ROUKF, 30 chars instead of 8):

loglevel = "DEBUG"
fmt_console = (
    f"<lvl>{{level:<{len(loglevel)}}}</> | "
    "<c>{extra[classname]:<30}:{function:<30}</> - <lvl>{message}</>"
)
fmt_file = (
    f"{{time:YYYY-MM-DDTHH:mm:ss.SSS}} ({{elapsed}}) | {{level:<{len(loglevel)}}} | "
    "{extra[classname]:<30}:{function:<30} - {message}"
)


...

# something like:
    default_logger(
        Path(options_fsi["io"]["write_path"]).joinpath("run.log"),
        level=loglevel,
        fmt_console=fmt_console,
        fmt_file=fmt_file,
    )

@m.locke

Edited by D.J. Nolte

Merge request reports

Loading