hynek / structlog

Simple, powerful, and fast logging for Python.
https://www.structlog.org/
Other
3.48k stars 220 forks source link

Feature request: re-order output columns without explicitly defining them #622

Open jwuerzinger opened 4 months ago

jwuerzinger commented 4 months ago

Following up on https://github.com/hynek/structlog/issues/388, it would be really nice to add an option to reorder columns without having to explicitly define colours etc.

I.e. changing sth like this:

 2021-12-25 00:08:19 [debug    ] running in verbose mode        [myapp]

into e.g.

 2021-12-25 00:08:19 [myapp] [debug    ] running in verbose mode

with e.g. something like:

processors=structlog.get_config()["processors"]
processors[-1].reorder_columns([0, 3, 1, 2])
structlog.configure( processors=processors )
hynek commented 4 months ago

I guess you can do that by mangling processors[-1]._columns for now.