Skip to content

Commit

Permalink
Initialize defaults in init
Browse files Browse the repository at this point in the history
Signed-off-by: Vince Prignano <[email protected]>
  • Loading branch information
vincepri committed Aug 13, 2019
1 parent 4527d85 commit 9007a3f
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions klog.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,31 +396,23 @@ type flushSyncWriter interface {
io.Writer
}

// init sets up the defaults and runs flushDaemon.
func init() {
// Default stderrThreshold is ERROR.
logging.stderrThreshold = errorLog

logging.stderrThreshold = errorLog // Default stderrThreshold is ERROR.
logging.setVState(0, nil, false)
logging.logDir = ""
logging.logFile = ""
logging.logFileMaxSizeMB = 1800
logging.toStderr = true
logging.alsoToStderr = false
logging.skipHeaders = false
logging.addDirHeader = false
logging.skipLogHeaders = false
go logging.flushDaemon()
}

var initDefaultsOnce sync.Once

// InitFlags is for explicitly initializing the flags.
func InitFlags(flagset *flag.FlagSet) {

// Initialize defaults.
initDefaultsOnce.Do(func() {
logging.logDir = ""
logging.logFile = ""
logging.logFileMaxSizeMB = 1800
logging.toStderr = true
logging.alsoToStderr = false
logging.skipHeaders = false
logging.addDirHeader = false
logging.skipLogHeaders = false
})

if flagset == nil {
flagset = flag.CommandLine
}
Expand Down

0 comments on commit 9007a3f

Please sign in to comment.