logger

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

func Debugf

func Debugf(template string, args ...interface{})

func Error

func Error(args ...interface{})

func Errorf

func Errorf(template string, args ...interface{})

func Fatal

func Fatal(args ...interface{})

func Fatalf

func Fatalf(template string, args ...interface{})

func Info

func Info(args ...interface{})

func Infof

func Infof(template string, args ...interface{})

func Init

func Init(options ...Option) error

func Log

func Log(level Level, format string, v ...interface{})

func NewContext

func NewContext(ctx context.Context, logger Logger) context.Context

func String

func String() string

func Trace

func Trace(args ...interface{})

func Tracef

func Tracef(template string, args ...interface{})

func Warn

func Warn(args ...interface{})

func Warnf

func Warnf(template string, args ...interface{})

Types

type Helper

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

func NewHelper

func NewHelper(logger Logger) *Helper

func (*Helper) Debug

func (h *Helper) Debug(args ...interface{})

func (*Helper) Debugf

func (h *Helper) Debugf(template string, args ...interface{})

func (*Helper) Error

func (h *Helper) Error(args ...interface{})

func (*Helper) Errorf

func (h *Helper) Errorf(template string, args ...interface{})

func (*Helper) Fatal

func (h *Helper) Fatal(args ...interface{})

func (*Helper) Fatalf

func (h *Helper) Fatalf(template string, args ...interface{})

func (*Helper) Info

func (h *Helper) Info(args ...interface{})

func (*Helper) Infof

func (h *Helper) Infof(template string, args ...interface{})

func (*Helper) Trace

func (h *Helper) Trace(args ...interface{})

func (*Helper) Tracef

func (h *Helper) Tracef(template string, args ...interface{})

func (*Helper) Warn

func (h *Helper) Warn(args ...interface{})

func (*Helper) Warnf

func (h *Helper) Warnf(template string, args ...interface{})

func (*Helper) WithError

func (h *Helper) WithError(err error) *Helper

func (*Helper) WithFields

func (h *Helper) WithFields(fields map[string]interface{}) *Helper

type Level

type Level int8
const (
	TraceLevel Level = iota - 2
	DebugLevel
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel
)

func GetLevel

func GetLevel(levelStr string) (Level, error)

func (Level) Enable

func (level Level) Enable(lvl Level) bool

func (Level) LevelForGorm

func (level Level) LevelForGorm() int

func (Level) String

func (level Level) String() string

type Logger

type Logger interface {
	Init(options ...Option) error
	Options() Options
	Fields(fields map[string]interface{}) Logger
	Log(level Level, v ...interface{})
	Logf(level Level, format string, v ...interface{})
	String() string
}
var (
	DefaultLogger Logger
)

func Fields

func Fields(fields map[string]interface{}) Logger

func FromContext

func FromContext(ctx context.Context) (Logger, bool)

func NewLogger

func NewLogger(opts ...Option) Logger

type Option

type Option func(*Options)

func SetOption

func SetOption(k, v interface{}) Option

func WithCallerSkipCount

func WithCallerSkipCount(c int) Option

func WithFields

func WithFields(fileds map[string]interface{}) Option

func WithLevel

func WithLevel(level Level) Option

func WithOutPut

func WithOutPut(out io.Writer) Option

type Options

type Options struct {
	Level           Level
	Fields          map[string]interface{}
	Out             io.Writer
	CallerSkipCount int
	Context         context.Context
}

Jump to

Keyboard shortcuts

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