logger

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug added in v1.0.2

func Debug(args ...interface{})

func Debugf added in v1.0.2

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

func Error added in v1.0.2

func Error(args ...interface{})

func Errorf added in v1.0.2

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

func Fatal added in v1.0.2

func Fatal(args ...interface{})

func Fatalf added in v1.0.2

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

func Info

func Info(args ...interface{})

func Infof added in v1.0.2

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 added in v1.0.2

func Trace(args ...interface{})

func Tracef added in v1.0.2

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

func Warn added in v1.0.2

func Warn(args ...interface{})

func Warnf added in v1.0.2

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