structlog icon indicating copy to clipboard operation
structlog copied to clipboard

How to change log format order ?

Open byt3bl33d3r opened this issue 4 years ago • 2 comments

Heya,

Amazing project. I've started using structlog for all my stuff. This is a really dumb question but I honestly couldn't find it "spelled out" for me anywhere.

I'm trying to change the log format of structlogs. This can be accomplished by a format string using Python's stdlib logger.

Basically my current log output is the following:

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

I want to put the logger name before the log level, e.g.:

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

How does one accomplish this?

byt3bl33d3r avatar Dec 25 '21 00:12 byt3bl33d3r

Unfortunately, that's currently not supported. You can copy-paste ConsoleRenderer from dev.py and just adjust the order in there. :)

hynek avatar Dec 25 '21 14:12 hynek

gotchu. Thanks for the response!

byt3bl33d3r avatar Dec 25 '21 15:12 byt3bl33d3r

@hynek I wonder if you are interested in this feature. I'd like to invest some time here.

atugushev avatar Oct 25 '23 16:10 atugushev

I think this is a bit more complicated than it sounds, because it interacts with #341 and should be tackled together.

I'm thinking something like [Column("timestamp", foreground="green", background="violet"), Column("event", ...)]

hynek avatar Oct 30 '23 14:10 hynek

Please everyone interested, look/comment at/on #577.

hynek avatar Dec 20 '23 10:12 hynek