package levels
import "github.com/go-kit/kit/log/deprecated_levels"
Package levels implements leveled logging on top of Go kit's log package.
Deprecated: Use github.com/go-kit/log/level instead.
Index ¶
- type Levels
- func New(logger log.Logger, options ...Option) Levels
- func (l Levels) Crit() log.Logger
- func (l Levels) Debug() log.Logger
- func (l Levels) Error() log.Logger
- func (l Levels) Info() log.Logger
- func (l Levels) Warn() log.Logger
- func (l Levels) With(keyvals ...interface{}) Levels
- type Option
Examples ¶
Types ¶
type Levels ¶
type Levels struct {
// contains filtered or unexported fields
}
Levels provides a leveled logging wrapper around a logger. It has five
levels: debug, info, warning (warn), error, and critical (crit). If you
want a different set of levels, you can create your own levels type very
easily, and you can elide the configuration.
Code:play
Output:Example¶
package main
import (
"os"
levels "github.com/go-kit/kit/log/deprecated_levels"
"github.com/go-kit/log"
)
func main() {
logger := levels.New(log.NewLogfmtLogger(os.Stdout))
logger.Debug().Log("msg", "hello")
logger.With("context", "foo").Warn().Log("err", "error")
}
level=debug msg=hello
level=warn context=foo err=error
func New ¶
New creates a new leveled logger, wrapping the passed logger.
func (Levels) Crit ¶
Crit returns a critical level logger.
func (Levels) Debug ¶
Debug returns a debug level logger.
func (Levels) Error ¶
Error returns an error level logger.
func (Levels) Info ¶
Info returns an info level logger.
func (Levels) Warn ¶
Warn returns a warning level logger.
func (Levels) With ¶
With returns a new leveled logger that includes keyvals in all log events.
type Option ¶
type Option func(*Levels)
Option sets a parameter for leveled loggers.
func CritValue ¶
CritValue sets the value for the field used to indicate the critical log level. By default, the value is "crit".
func DebugValue ¶
DebugValue sets the value for the field used to indicate the debug log level. By default, the value is "debug".
func ErrorValue ¶
ErrorValue sets the value for the field used to indicate the error log level. By default, the value is "error".
func InfoValue ¶
InfoValue sets the value for the field used to indicate the info log level. By default, the value is "info".
func Key ¶
Key sets the key for the field used to indicate log level. By default, the key is "level".
func WarnValue ¶
WarnValue sets the value for the field used to indicate the warning log level. By default, the value is "warn".
Source Files ¶
- Version
- v0.13.0 (latest)
- Published
- May 29, 2023
- Platform
- linux/amd64
- Imports
- 1 packages
- Last checked
- 3 weeks ago –
Tools for package owners.