phuslu / log

Fastest structured logging
MIT License
672 stars 44 forks source link

stdout/stderr based on log level #69

Closed fireflycons closed 5 months ago

fireflycons commented 5 months ago

Hi @phuslu

Here's another suggestion 😁

Some log forwarders like filebeat can switch on the stream on which logs are emitted. It would be nice if for the standard logger type we could select the output stream based on the log level, e.g. severity of warning or higher goes to stderr and lower levels go to stdout. User can set at which level the change from stdout to stderr happens.

phuslu commented 5 months ago

looks like multiple-dispatching-writer does https://github.com/phuslu/log?tab=readme-ov-file#multiple-dispatching-writer

let me check it can meet the requirement or we could enhance the writer.

phuslu commented 5 months ago

After consideration, I think it's no needed to introduce a new Writer but worth to add a helper/type function to make it easier.

So I add a commit https://github.com/phuslu/log/commit/df27c525537fa4fc2c452d09a0af7b7d25425ccf

@fireflycons could you please take a look the example here https://github.com/phuslu/log?tab=readme-ov-file#customize-the-log-writer ? If OK, I'd like release a new tag.

fireflycons commented 5 months ago

Nice - go for it!

phuslu commented 5 months ago

v1.0.93 tagged/released, thanks