log

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package log defines the logger interfaces used by pulsar client. Users can leverage these interfaces to provide a customized logger implementation.

The Logger and Entry interfaces defined here are inspired by sirupsen/logrus, both logrus and zap logging libraries are good resources to learn how to implement a effective logging library.

Besides the interfaces, this log library also provides an implementation based on logrus, and a No-op one as well.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry interface {
	WithFields(fields Fields) Entry
	WithField(name string, value interface{}) Entry

	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})

	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
}

Entry describes the interface for the logger entry.

type Fields

type Fields map[string]interface{}

Fields type, used to pass to `WithFields`.

type Logger

type Logger interface {
	SubLogger(fields Fields) Logger

	WithFields(fields Fields) Entry
	WithField(name string, value interface{}) Entry
	WithError(err error) Entry

	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})

	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
}

Logger describes the interface that must be implemeted by all loggers.

func DefaultNopLogger

func DefaultNopLogger() Logger

DefaultNopLogger returns a nop logger.

func NewLoggerWithLogrus

func NewLoggerWithLogrus(logger *logrus.Logger) Logger

NewLoggerWithLogrus creates a new logger which wraps the given logrus.Logger

Jump to

Keyboard shortcuts

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