Skip to content

Commit

Permalink
docs: unify godoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zbindenren committed Dec 24, 2020
1 parent f36e342 commit 82d61d1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions flash.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"go.uber.org/zap/zapcore"
)

// Logger is the flash logger which embeds a zap.SugaredLogger.
// Logger is the flash logger which embeds a `zap.SugaredLogger`.
type Logger struct {
*zap.SugaredLogger
atom zap.AtomicLevel
Expand All @@ -37,23 +37,23 @@ func WithoutCaller() Option {
}
}

// WithSink changes the default zap stderr sink.
// WithSink changes the default zap `stderr` sink.
func WithSink(name string) Option {
return func(c *config) {
c.sink = name
}
}

// WithDebug enables or disables debug log level.
// WithDebug enables or disables `DebugLevel`.
func WithDebug(debug bool) Option {
return func(c *config) {
c.isDebug = debug
}
}

// WithStacktrace completely enables automatic stacktrace capturing. Stacktraces
// are captured on ErrorLevel and above when in debug mode. When not in debug mode,
// only FatalLevel messages contain stacktraces.
// are captured on `ErrorLevel` and above when in debug mode. When not in debug mode,
// only `FatalLevel` messages contain stacktraces.
func WithStacktrace() Option {
return func(c *config) {
c.disableStacktrace = false
Expand Down Expand Up @@ -83,7 +83,7 @@ func WithPrometheus(appName string, registry prometheus.Registerer) Option {
}

// New creates a new Logger. If no options are specified, stacktraces and color output are disabled and
// the confgured level is `info`.
// the confgured level is `InfoLevel`.
func New(opts ...Option) *Logger {
l := zap.New(nil) // noop logger
atom := zap.NewAtomicLevelAt(zap.InfoLevel)
Expand Down Expand Up @@ -148,7 +148,7 @@ func New(opts ...Option) *Logger {
}
}

// SetDebug enables or disables debug level.
// SetDebug enables or disables `DebugLevel`.
func (l *Logger) SetDebug(d bool) {
level := zap.DebugLevel
stackTraceLevel := zap.ErrorLevel
Expand All @@ -165,15 +165,15 @@ func (l *Logger) SetDebug(d bool) {
l.stackTrace(stackTraceLevel)
}

// Disable disables (nearly) all output. Only fatal errors are logged.
// Disable disables (nearly) all output. Only `FatalLevel` errors are logged.
func (l *Logger) Disable() {
l.m.Lock()
l.currentLevel = zapcore.FatalLevel
l.m.Unlock()
l.atom.SetLevel(zap.FatalLevel)
}

// SetLevel sets the chosen level.
// SetLevel sets the chosen level. If stacktraces are enabled, it adjusts stacktrace levels accordingly.
func (l *Logger) SetLevel(level zapcore.Level) {
l.m.Lock()
oldLevel := l.currentLevel
Expand Down

0 comments on commit 82d61d1

Please sign in to comment.