github.com/Cloud-Foundations/Dominator@v0.3.4/lib/log/cmdlogger/api.go (about) 1 package cmdlogger 2 3 import ( 4 "io" 5 "os" 6 7 "github.com/Cloud-Foundations/Dominator/lib/log/debuglogger" 8 ) 9 10 type Options struct { 11 Datestamps bool 12 DebugLevel int // Supported range: -1 to 32767. 13 Subseconds bool 14 Writer io.Writer 15 } 16 17 var stdOptions = Options{Writer: os.Stderr} 18 19 // GetStandardOptions will return the standard options. 20 // The following command-line flags are registered and used: 21 // 22 // -logDatestamps: if true, prefix logs with datestamps 23 // -logDebugLevel: debug log level 24 // -logSubseconds: if true, datestamps will have subsecond resolution 25 // The standard error is used for the output. 26 func GetStandardOptions() Options { return stdOptions } 27 28 // New will create a debuglogger.Logger with the standard options. 29 func New() *debuglogger.Logger { 30 return newLogger(stdOptions) 31 } 32 33 // NewWithOptions will create a debuglogger.Logger with the specified options. 34 func NewWithOptions(options Options) *debuglogger.Logger { 35 return newLogger(options) 36 } 37 38 // SetDatestampsDefault will change the default for the -logDatestamps command 39 // line flag. This should be called before flag.Parse(). 40 func SetDatestampsDefault(defaultValue bool) { 41 stdOptions.Datestamps = defaultValue 42 }