github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/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 65535. 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 // -logDatestamps: if true, prefix logs with datestamps 22 // -logDebugLevel: debug log level 23 // -logSubseconds: if true, datestamps will have subsecond resolution 24 // The standard error is used for the output. 25 func GetStandardOptions() Options { return stdOptions } 26 27 // New will create a debuglogger.Logger with the standard options. 28 func New() *debuglogger.Logger { 29 return newLogger(stdOptions) 30 } 31 32 // NewWithOptions will create a debuglogger.Logger with the specified options. 33 func NewWithOptions(options Options) *debuglogger.Logger { 34 return newLogger(options) 35 } 36 37 // SetDatestampsDefault will change the default for the -logDatestamps command 38 // line flag. This should be called before flag.Parse(). 39 func SetDatestampsDefault(defaultValue bool) { 40 stdOptions.Datestamps = defaultValue 41 }