phuslu / log

Fastest structured logging
MIT License
672 stars 44 forks source link

Support global level #53

Closed MisLink closed 2 years ago

MisLink commented 2 years ago

close #52

phuslu commented 2 years ago

Could you add a simple test?

Although almost tests of this lib does not check/ensure the test result is correct, but have a test is better, because we could run it by "go test -v" then check result by our eyes. :D

phuslu commented 2 years ago

thanks, let me check this pr locally then merge it if no issues this night.

phuslu commented 2 years ago

Reverted, need find way to avoid performance hit.

see https://github.com/phuslu/log/runs/6489242631?check_suite_focus=true

Now "BenchmarkDisablePhusLog" is slower than zerolog if have this PR.

phuslu commented 2 years ago

unroll slient() in https://github.com/phuslu/log/commit/0f4ff05606ba48b99647dc836b1e7e4c66557585 cannot avoid performance hit.

https://github.com/phuslu/log/runs/6489809266?check_suite_focus=true

MisLink commented 2 years ago

Well, zerolog doesn't support to change level for a logger. It can only call Level(lvl) to create a new logger with lvl. Because of it, zerolog can avoid one atomic call. It seems there is not much to improve it.

phuslu commented 2 years ago

create a new logger

the "create a new logger" is expensive in critical(hot) path of high QPS server, that's why I choose atomic call(an in-place operation) to do this.