Open stepanstipl opened 7 years ago
any update on this?
I dug in a little more and wanted to share my findings
While not ideal, it appears that you gain some control over the logging level if you toggle the infoEvents
map in listener.go
. This will work if you vendor libcompose
and either want the logging level at info or debug. I don't see a way to interface with this map at run time. Ideally libcompose respects logrus settings and a developer wouldn't need to modify this map.
https://github.com/docker/libcompose/blob/master/project/listener.go
I wanted to isolate the log level to a single log so I created the linked gist below. Toggling the log-level on this script shows that the log call to logrus.Infof("Recreating %s", s.name)
in /libcompose/docker/service/service.go
is unable to be suppressed. Reason is still unclear.
https://gist.github.com/andscoop/3a30a42b8f977cc8f85cf5c6e0297afd
One last note - there are a few places where contributors printed to standard out vs logging which will make it impossible to control the logging level via this method https://github.com/docker/libcompose/blob/master/docker/network/network.go#L49
Seems it is possible to control the logging level in libcompose@v0.4.1-0.20171025083809-57bd716502dc
Example:
originalLevel := log.GetLevel()
log.SetLevel(log.FatalLevel) // TODO: this is a hack to prevent libcompose from printing errors to the console.
err := proj.Parse()
log.SetLevel(originalLevel) // TODO: this is a hack to prevent libcompose from printing errors to the console.
The above code allows libcompose
to be used to detect if a file is a docker-compose
file or not.
Usually it prints a bunch of errors if the file is not a valid docker-compose
file, but with above code it does not.
Hi, I can't seem to be able to get libcompose to respect my logger settings.
If I do smth like:
typically libraries using logrus would respect my logger settings (level & format).
I can't get it working with
libcompose
, for some reason I'll still see all the logs from info level above with default formatting.Any idea why is this not working/how I can suppress logs from libcompose? Any help appreciated, cheers.