Re: [go-nuts] how to design log package to avoid allocations

2020-03-09 Thread Marcin Romaszewicz
I'm using Uber's zap logger in production systems ( https://github.com/uber-go/zap). It is designed to emit structured JSON logs and do the minimal amount of allocations possible. It's a completely different interface from Go's log package, but that is where the efficiency comes from. I'd highly

Re: [go-nuts] how to design log package to avoid allocations

2020-03-09 Thread Vasiliy Tolstov
пн, 9 мар. 2020 г. в 19:36, Axel Wagner : > IMO, there really isn't a super good answer. The simple answer is: You > need to delay the actual `fmt.Sprintf` call as long as possible. Which > generally means, that the interface you consume (to allow the user to > direct and configure logging) will

Re: [go-nuts] how to design log package to avoid allocations

2020-03-09 Thread Vasiliy Tolstov
пн, 9 мар. 2020 г. в 19:41, andrey mirtchovski : > to avoid allocations you have to hint at the type of what you're going > to print. for example see/use zerolog: https://github.com/rs/zerolog Tanks, I saw it. But mostly i want to avoid typing hint -- Vasiliy Tolstov, e-mail:

Re: [go-nuts] how to design log package to avoid allocations

2020-03-09 Thread andrey mirtchovski
to avoid allocations you have to hint at the type of what you're going to print. for example see/use zerolog: https://github.com/rs/zerolog On Mon, Mar 9, 2020 at 10:36 AM 'Axel Wagner' via golang-nuts wrote: > > IMO, there really isn't a super good answer. The simple answer is: You need > to

Re: [go-nuts] how to design log package to avoid allocations

2020-03-09 Thread 'Axel Wagner' via golang-nuts
IMO, there really isn't a super good answer. The simple answer is: You need to delay the actual `fmt.Sprintf` call as long as possible. Which generally means, that the interface you consume (to allow the user to direct and configure logging) will need to reflect formatting and all kinds of things

[go-nuts] how to design log package to avoid allocations

2020-03-09 Thread Vasiliy Tolstov
Hi! I have some logging package and after memory profiling saw that for disabled log levels i'm allocate memory for message. For example i'm send in logger only Info level. So i want to avoid Debug/Trace stuff. but memory profiling says that for call log.Tracef("my message %v", msg) i'm allocate