Skip to content

Commit

Permalink
Merge pull request #13 from michael-berlin/fix_log_before_flag_parse
Browse files Browse the repository at this point in the history
Export glog bugfix.
  • Loading branch information
robpike committed Jul 31, 2015
2 parents 44145f0 + 65d6746 commit fca8c88
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion glog.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,10 @@ func (l *loggingT) output(s severity, buf *buffer, file string, line int, alsoTo
}
}
data := buf.Bytes()
if l.toStderr {
if !flag.Parsed() {

This comment has been minimized.

Copy link
@antmanler

antmanler Aug 13, 2015

This will stop user to use 3rd party flag, such as github.com/spf13/pflag

This comment has been minimized.

Copy link
@absolute8511

absolute8511 Dec 25, 2015

I agree with @antmanler , and also not working with the flag object returned by flag.NewFlagSet. Maybe the best solution is to allow the glog working with the specific FlagSet object not only the default object in flag package.

This comment has been minimized.

Copy link
@arvenil

arvenil Jan 3, 2018

Breaks many libraries. Just google "ERROR: logging before flag.Parse". People are adding flag.CommandLine.Parse([]string{}) as a workaround to their code bases: cloudnativelabs/kube-router@78a0aeb

os.Stderr.Write([]byte("ERROR: logging before flag.Parse: "))
os.Stderr.Write(data)
} else if l.toStderr {
os.Stderr.Write(data)
} else {
if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() {
Expand Down

0 comments on commit fca8c88

Please sign in to comment.