@@ -209,7 +209,13 @@ func NewRaw(opts ...Opts) *zap.Logger {
209
209
return log
210
210
}
211
211
212
- // BindToFlagSet func allows CLI passed flags to be parsed.
212
+ // BindFlags will parse the given flagset for zap option flags and set the log options accordingly
213
+ // zap-devel: Development Mode defaults(encoder=consoleEncoder,logLevel=Debug,stackTraceLevel=Warn)
214
+ // Production Mode defaults(encoder=jsonEncoder,logLevel=Info,stackTraceLevel=Error)
215
+ // zap-encoder: Zap log encoding ('json' or 'console')
216
+ // zap-log-level: Zap Level to configure the verbosity of logging. Can be one of 'debug', 'info', 'error',
217
+ // or any integer value > 0 which corresponds to custom debug levels of increasing verbosity")
218
+ // zap-stacktrace-level: Zap Level at and above which stacktraces are captured (one of 'warn' or 'error')
213
219
func (o * Options ) BindFlags (fs * flag.FlagSet ) {
214
220
215
221
// Set Development mode value
@@ -242,7 +248,10 @@ func (o *Options) BindFlags(fs *flag.FlagSet) {
242
248
"Zap Level at and above which stacktraces are captured (one of 'warn' or 'error')" )
243
249
}
244
250
245
- // UseFlagOptions to set logger with CLI passed flags.
251
+ // UseFlagOptions configures the logger to use the Options set by parsing zap option flags from the CLI.
252
+ // opts := zap.Options{}
253
+ // opts.BindFlags(flag.CommandLine)
254
+ // log := zap.New(zap.UseFlagOptions(&opts))
246
255
func UseFlagOptions (in * Options ) Opts {
247
256
return func (o * Options ) {
248
257
* o = * in
0 commit comments