zap icon indicating copy to clipboard operation
zap copied to clipboard

Added OnLevel method to allow for configurable log level

Open dahankzter opened this issue 6 years ago • 9 comments

I do this in a custom middleware I have in my project but I thought why not use your published version. I do need to be able to switch levels however so did this.

What do you think?

dahankzter avatar Jul 20 '17 11:07 dahankzter

Ping @appleboy would this be of interest?

dahankzter avatar Jul 31 '17 12:07 dahankzter

how to change log level?

appleboy avatar Jul 31 '17 14:07 appleboy

Zap has an atomic level zapcore.AtomicLevel that can be changed runtime safely.

If you give the constructor in this patch a given level say DebugLevel it will only log on that level and combined with the AtomicLogger you can switch on and off that behaviour.

As for how you signal the app is up to the application creator. I often use a Nats channel or a Zeromq to broadcast changes like these but you could do whatever suits you I guess.

dahankzter avatar Jul 31 '17 19:07 dahankzter

If you want to I can provide an example in the example directory as well.

dahankzter avatar Jul 31 '17 19:07 dahankzter

I hope the example isn't too messy @appleboy does this work?

dahankzter avatar Jul 31 '17 19:07 dahankzter

I really don't know why the check failed.

dahankzter avatar Aug 01 '17 07:08 dahankzter

I have no idea what the check that fails mean:

The command "embedmd -d *.md" exited with 2.

dahankzter avatar Aug 03 '17 13:08 dahankzter

@dahankzter because you change the example code, please also update the readme.

see more detail about embedmd tool github.com/campoy/embedmd

appleboy avatar Aug 04 '17 00:08 appleboy

conflicts.

appleboy avatar Dec 06 '18 03:12 appleboy

fixed in #53

appleboy avatar Nov 27 '23 15:11 appleboy