automaxprocs icon indicating copy to clipboard operation
automaxprocs copied to clipboard

The log format should be configurable or customizable

Open xdlai opened this issue 5 years ago • 5 comments

After import automaxprocs, the process will print "2019/07/09 14:18:22 maxprocs: Leaving GOMAXPROCS=2: CPU quota undefined" through STDOUT. There is no information to identify this line is an INFO, WARNING or ERROR log.

If the log format is configurable or customizable, the service using automaxprocs can generate the log message properly.

xdlai avatar Jul 12 '19 11:07 xdlai

I agree

dpanic avatar Jul 13 '19 08:07 dpanic

I would like to disable this log all together.

prestonvanloon avatar Jul 14 '19 02:07 prestonvanloon

For the simple integration case (import _ "go.uber.org/automaxprocs"), it won't be possible to customize the behaviour as the initfunction ofautomaxprocs` would run before anything else could set the logger format, and it would require global configurations which will cause confusion if multiple packages try to set different values.

Instead, users who want customizations should use go.uber.org/automaxprocs/maxprocs and call Set with options. By default, maxprocs.Set doesn't log anything. You can customize where the output goes, but it's not possible to control the format. It probably makes sense to add a hook with information about what changes Set makes to allow users to log in any format.

I would like to disable this log all together.

You can use Set above which won't log. We wanted to log by default, as setting a global like GOMAXPROCS is a significant change which would be surprising if it was done silently because some package imported automaxprocs.

prashantv avatar Jul 15 '19 09:07 prashantv

The simple answer to this request is: use package go.uber.org/automaxprocs/maxprocs instead of go.uber.org/automaxprocs.

So the remaining issue is about documentation: go.uber.org/automaxprocs/maxprocs is not mentioned in the package documentation for automaxprocs.

dolmen avatar Nov 09 '23 17:11 dolmen