klogrus

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2023 License: BSD-3-Clause Imports: 3 Imported by: 2

README

klogrus

klogrus is a plug-in package to use logrus as a kgo.Logger

To use,

cl, err := kgo.NewClient(
        kgo.WithLogger(klogrus.New(logrusLogger)),
        // ...other opts
)

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldLogger

type FieldLogger interface {
	logrus.FieldLogger
	GetLevel() logrus.Level
}

FieldLogger interface combines logrus.FieldLogger with GetLevel method useful to represent a wrapper around *logrus.Logger.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger provides the kgo.Logger interface for usage in kgo.WithLogger when initializing a client.

func New

func New(lr *logrus.Logger) *Logger

New returns a new Logger using a *logrus.Logger instance.

Example
package main

import (
	"github.com/sirupsen/logrus"

	"github.com/twmb/franz-go/pkg/kgo"
	"github.com/twmb/franz-go/plugin/klogrus"
)

func main() {
	l := klogrus.New(logrus.New())

	l.Log(kgo.LogLevelInfo, "test message", "test-key", "test-val")
}
Output:

func NewFieldLogger

func NewFieldLogger(fl FieldLogger) *Logger

NewFieldLogger returns a new Logger using a FieldLogger interface. it is isofunctional with New constructor, except it can accept either *logrus.Logger or a possible wrapper that implements logrus.FieldLogger and includes GetLevel method.

func (*Logger) Level

func (l *Logger) Level() kgo.LogLevel

Level is for the kgo.Logger interface.

func (*Logger) Log

func (l *Logger) Log(level kgo.LogLevel, msg string, keyvals ...any)

Log is for the kgo.Logger interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL