log

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: MIT Imports: 14 Imported by: 48

Documentation

Index

Constants

View Source
const (
	LevelTrace = Level(1000)
	LevelDebug = Level(2000)
	LevelInfo  = Level(3000)
	LevelWarn  = Level(4000)
	LevelError = Level(5000)
	LevelFatal = Level(6000)
	LevelPanic = Level(7000)
)
View Source
const (
	GlobalLoggerName = "global"
)

Variables

View Source
var (
	ErrIllegalLevel = errors.New("illegal level")
)

Functions

func AsStdLogger

func AsStdLogger(in CoreLogger, logAs Level) *stdlog.Logger

func ConfigureStd added in v0.1.3

func ConfigureStd()

func ConfigureStdWith added in v0.1.3

func ConfigureStdWith(in CoreLogger, logAs Level)

func Debug

func Debug(args ...interface{})

func Debugf

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

func Error

func Error(args ...interface{})

func Errorf

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

func Fatal

func Fatal(args ...interface{})

func Fatalf

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

func GetErrorOf

func GetErrorOf(fields fields.Fields, using Provider) error

func GetLoggerOf

func GetLoggerOf(fields fields.Fields, using Provider) *string

func GetMessageOf

func GetMessageOf(fields fields.Fields, using Provider) *string

func GetTimestampOf

func GetTimestampOf(fields fields.Fields, using Provider) *time.Time

func Info

func Info(args ...interface{})

func Infof

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

func IsDebugEnabled

func IsDebugEnabled() bool

func IsErrorEnabled

func IsErrorEnabled() bool

func IsFatalEnabled

func IsFatalEnabled() bool

func IsInfoEnabled

func IsInfoEnabled() bool

func IsLevelEnabled

func IsLevelEnabled(level Level) bool

func IsPanicEnabled

func IsPanicEnabled() bool

func IsTraceEnabled

func IsTraceEnabled() bool

func IsWarnEnabled

func IsWarnEnabled() bool

func Log

func Log(level Level, args ...interface{})

func Logf

func Logf(level Level, format string, args ...interface{})

func Panic

func Panic(args ...interface{})

func Panicf

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

func SetProvider

func SetProvider(p Provider)

func Trace

func Trace(args ...interface{})

func Tracef

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

func Warn

func Warn(args ...interface{})

func Warnf

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

Types

type CoreLogger

type CoreLogger interface {
	GetName() string
	LogEvent(Event)
	IsLevelEnabled(Level) bool
	GetProvider() Provider
}

type Event

type Event interface {
	fields.Fields

	GetLevel() Level
	GetCallDepth() int
	GetContext() interface{}

	WithField(key string, value interface{}) Event
}

type EventImpl

type EventImpl struct {
	fields.Fields
	Level     Level
	CallDepth int
	Context   interface{}
}

func NewEvent

func NewEvent(level Level, f fields.Fields, callDepth int) *EventImpl

func (*EventImpl) GetCallDepth

func (instance *EventImpl) GetCallDepth() int

func (*EventImpl) GetContext

func (instance *EventImpl) GetContext() interface{}

func (*EventImpl) GetLevel

func (instance *EventImpl) GetLevel() Level

func (*EventImpl) WithField

func (instance *EventImpl) WithField(key string, value interface{}) Event

type Level

type Level uint16

func (Level) CompareTo

func (instance Level) CompareTo(o Level) int

func (Level) MarshalText

func (instance Level) MarshalText() (text []byte, err error)

func (Level) Set

func (instance Level) Set(plain string) error

func (Level) String

func (instance Level) String() string

func (*Level) UnmarshalText

func (instance *Level) UnmarshalText(text []byte) error

type LevelAware

type LevelAware interface {
	GetLevel() Level
	SetLevel(Level)
}

type LevelNames

type LevelNames interface {
	FromOrdinal(uint16) (string, error)
	ToOrdinal(string) (uint16, error)
}
var DefaultLevelNames LevelNames = &defaultLevelNames{}

type LevelProvider

type LevelProvider func() []Level
var DefaultLevelProvider LevelProvider = func() []Level {
	return defaultLevels
}

type Levels

type Levels []Level

func (Levels) Len

func (instance Levels) Len() int

func (Levels) Less

func (instance Levels) Less(i, j int) bool

func (Levels) Swap

func (instance Levels) Swap(i, j int)

type Logger

type Logger interface {
	CoreLogger

	Log(Level, ...interface{})
	Logf(Level, string, ...interface{})

	Trace(...interface{})
	Tracef(string, ...interface{})
	IsTraceEnabled() bool

	Debug(...interface{})
	Debugf(string, ...interface{})
	IsDebugEnabled() bool

	Info(...interface{})
	Infof(string, ...interface{})
	IsInfoEnabled() bool

	Warn(...interface{})
	Warnf(string, ...interface{})
	IsWarnEnabled() bool

	Error(...interface{})
	Errorf(string, ...interface{})
	IsErrorEnabled() bool

	Fatal(...interface{})
	Fatalf(string, ...interface{})
	IsFatalEnabled() bool

	Panic(...interface{})
	Panicf(string, ...interface{})
	IsPanicEnabled() bool

	With(name string, value interface{}) Logger
	Withf(name string, format string, args ...interface{}) Logger
	WithError(error) Logger
	WithFields(fields.Fields) Logger
}

func AsLogger

func AsLogger(in CoreLogger) Logger

func GetGlobalLogger added in v0.1.6

func GetGlobalLogger() Logger

func GetLogger

func GetLogger(name string) Logger

func NewLogger

func NewLogger(cl CoreLogger) Logger

func With

func With(name string, value interface{}) Logger

func WithError

func WithError(err error) Logger

func WithFields

func WithFields(fields fields.Fields) Logger

func Withf added in v0.1.3

func Withf(name string, format string, args ...interface{}) Logger

type Provider

type Provider interface {
	GetName() string

	GetLogger(name string) Logger

	GetAllLevels() []Level

	GetFieldKeySpec() fields.KeysSpec

	GetLevelNames() LevelNames
}

func AllProviders

func AllProviders() []Provider

func GetProvider

func GetProvider() Provider

func NewProvider

func NewProvider(name string, factory ProviderFactory, levels LevelProvider) Provider

func RegisterProvider

func RegisterProvider(p Provider) Provider

func UnregisterProvider

func UnregisterProvider(name string) Provider

type ProviderFactory

type ProviderFactory func(name string) Logger

type SimpleProvider

type SimpleProvider struct {
	Provider

	Level Level
	Out   io.Writer
}

func NewSimpleProvider

func NewSimpleProvider(name string) *SimpleProvider

func (*SimpleProvider) GetLevel

func (instance *SimpleProvider) GetLevel() Level

func (*SimpleProvider) SetLevel

func (instance *SimpleProvider) SetLevel(level Level)

type StdLogger

type StdLogger interface {
	CoreLogger

	Print(...interface{})
	Printf(string, ...interface{})
	Println(...interface{})

	Fatal(...interface{})
	Fatalf(string, ...interface{})
	Fatalln(...interface{})

	Panic(...interface{})
	Panicf(string, ...interface{})
	Panicln(...interface{})
}

func AsStdInterfacingLogger added in v0.1.3

func AsStdInterfacingLogger(in CoreLogger) StdLogger

type Writer added in v0.1.3

type Writer struct {
	CoreLogger
	LogAs Level
}

func (*Writer) Write added in v0.1.3

func (instance *Writer) Write(p []byte) (n int, err error)

Directories

Path Synopsis
internal
native module

Jump to

Keyboard shortcuts

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