logger

package
v1.6.2-rc Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package logger is the CNI logger interface, using logrus

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogLevel

func GetLogLevel() string

GetLogLevel get the log level from env.

func GetLogLocation

func GetLogLocation() string

GetLogLocation get the log location from env.

func GetLogReportCaller

func GetLogReportCaller() bool

Types

type Configuration

type Configuration struct {
	LogLevel     string
	LogLocation  string
	ReportCaller bool
}

Configuration stores the config of the logger.

func LoadLogConfig

func LoadLogConfig() *Configuration

LoadLogConfig returns the log configuration.

type Fields

type Fields map[string]interface{}

Fields Used when we want to call WithFields for structured logging.

type Hook

type Hook struct {
	Field string
	Skip  int

	Formatter func(file, function string, line int) string
	// contains filtered or unexported fields
}

func NewHook

func NewHook(levels ...logrus.Level) *Hook

func (*Hook) Fire

func (hook *Hook) Fire(entry *logrus.Entry) error

func (*Hook) Levels

func (hook *Hook) Levels() []logrus.Level

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})

	Debug(args ...interface{})

	DebugWithFields(fields Fields, args ...interface{})

	Infof(format string, args ...interface{})

	Info(args ...interface{})

	InfoWithFields(fields Fields, args ...interface{})

	Warnf(format string, args ...interface{})

	Warn(args ...interface{})

	WarnWithFields(fields Fields, args ...interface{})

	Errorf(format string, args ...interface{})

	Error(args ...interface{})

	ErrorWithFields(fields Fields, args ...interface{})

	Fatalf(format string, args ...interface{})

	Panicf(format string, args ...interface{})

	WithFields(fields Fields) Logger

	SetLogLevel(level string)
}

func GetLogger

func GetLogger() Logger

GetLogger return the default instance.

func New

func New(config *Configuration) Logger

New return new initializes logger.

Jump to

Keyboard shortcuts

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