Documentation ¶
Index ¶
- Constants
- Variables
- func NewLogger(opts ...LogOption) log.Logger
- func ParseFormat(formatName string) (format, error)
- type LogOption
- func Conditional(c bool, op LogOption) LogOption
- func Context(c []interface{}) LogOption
- func Debug(d bool) LogOption
- func FallbackLevel(l level.Value) LogOption
- func Format(f format) LogOption
- func FormatString(sf string) LogOption
- func Output(ou io.Writer) LogOption
- func With(kv ...interface{}) LogOption
Constants ¶
View Source
const ( JsonFormat format = iota LogfmtFormat )
Variables ¶
View Source
var ( // DefaultOutput is the default io.Writer where log messages are written (os.Stdout). DefaultOutput = os.Stdout // DefaultFormat is the default log format (json) // Available formats: json, logfmt DefaultFormat = JsonFormat // DefaultFallbackLevel is the default fallback level used in messages when a level is not defined. DefaultFallbackLevel level.Value = level.InfoValue() )
Functions ¶
func ParseFormat ¶
ParseFormat parses a string format name and returns the format or an error if the format is invalid.
Types ¶
type LogOption ¶
type LogOption func(o *options)
LogOption configures the option list.
func Conditional ¶ added in v0.2.0
Conditional applies an option if the condition is true. This is useful to avoid using conditional logic when building the option list.
func FallbackLevel ¶
FallbackLevel sets the default fallback level.
func FormatString ¶
FormatString accepts a string and tries to parse it as a log format. If the string cannot be parsed as a format, this method panics.
Other than that it behaves like Format.
Click to show internal directories.
Click to hide internal directories.