You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The library pulls in github.com/golang/glog for logging. That package installs global flags in the stdlib flag package, which means applications using embd get a bunch of flags pulled in by default, which is a bit unsightly.
For instance, I declared 3 flags for my app:
var (
pinID=flag.Int("pin", 10, "pin to use")
direction=flag.String("direction", "in", "in|out")
format=flag.String("format", "hex", "hex|bin")
)
flag.Parse()
...yet glog, thru embd, pollutes my command with a bunch of flags.
$ uartdump -h
Usage of uartdump:
-alsologtostderr
log to standard error as well as files
-direction string
in|out (default "in")
-format string
hex|bin (default "hex")
-log_backtrace_at value
when logging hits line file:N, emit a stack trace
-log_dir string
If non-empty, write log files in this directory
-logtostderr
log to standard error instead of files
-pin int
pin to use (default 10)
-stderrthreshold value
logs at or above this threshold go to stderr
-v value
log level for V logs
-vmodule value
comma-separated list of pattern=N settings for file-filtered logging
Note that in general, it's a bit of an anti-pattern for libraries to log. There's some cases where it makes sense tho, and in those case libraries should avoid linking against a specific implementation and instead take an injectable interface.
I've seen only 1 such usage of glog and it feels to me that it isn't necessary. If my argument makes sense to you, I'm happy to send a PR.
The text was updated successfully, but these errors were encountered:
aybabtme
changed the title
avoid using glog in the library
avoid logging in the library, and avoid using glog
Jul 29, 2016
The library pulls in
github.com/golang/glog
for logging. That package installs global flags in the stdlibflag
package, which means applications usingembd
get a bunch of flags pulled in by default, which is a bit unsightly.For instance, I declared 3 flags for my app:
...yet
glog
, thruembd
, pollutes my command with a bunch of flags.Note that in general, it's a bit of an anti-pattern for libraries to log. There's some cases where it makes sense tho, and in those case libraries should avoid linking against a specific implementation and instead take an injectable interface.
I've seen only 1 such usage of
glog
and it feels to me that it isn't necessary. If my argument makes sense to you, I'm happy to send a PR.The text was updated successfully, but these errors were encountered: