logging

package
v0.0.0-...-2b06aff Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Discard = log.New(ioutil.Discard, "", 0)

Discard logger used when no `Logger` and `writer` configures

Functions

func ConfigureWithContent

func ConfigureWithContent(str []byte) error

func ConfigureWithFile

func ConfigureWithFile(path string) error

func ConfigureWithString

func ConfigureWithString(str string) error

func DefaultPrefixWidth

func DefaultPrefixWidth() int

func GetLogger

func GetLogger(prefix string) *log.Logger

func GetLoggerOpt

func GetLoggerOpt(prefix string, opt int) *log.Logger

func IsTTY

func IsTTY(out io.Writer) bool

func LogAction

func LogAction(prefix string, action string)

func LogActionf

func LogActionf(prefix string, format string, args ...interface{})

func LogError

func LogError(prefix string, action string, err error)

func LogErrorf

func LogErrorf(prefix string, err error, format string, args ...interface{})

func LogLevelName

func LogLevelName(level Level) string

func LogTarget

func LogTarget(prefix string, action string, target interface{})

func SetDefaultLevel

func SetDefaultLevel(lvl Level)

func SetDefaultPrefixWidth

func SetDefaultPrefixWidth(width int)

func SetDefaultWriter

func SetDefaultWriter(out io.Writer)

func SetLevel

func SetLevel(name string, lvl Level)

func StringToLogLevelHookFunc

func StringToLogLevelHookFunc(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error)

Types

type Config

type Config struct {
	Name               string        `yaml:"name" json:"name"`
	Console            bool          `yaml:"console" json:"console"`
	Filename           string        `yaml:"filename" json:"filename"`
	Append             bool          `yaml:"append" json:"append"`
	RotateSchedule     string        `yaml:"roateSchedule" json:"rotateSchedule"`
	MaxSize            int           `yaml:"maxSize" json:"maxSize"`
	MaxBackups         int           `yaml:"maxBackups" json:"maxBackups"`
	MaxAge             int           `yaml:"maxAge" json:"maxAge"`
	Compress           bool          `yaml:"compress" json:"compress"`
	Levels             []LevelConfig `yaml:"levels" json:"levels"`
	DefaultPrefixWidth int           `yaml:"defaultPrefixWidth" json:"defaultPrefixWidth"`
	DefaultLevel       Level         `yaml:"defaultLevel" json:"defaultLevel"`
}

type Level

type Level int
const (
	LevelAll Level = iota
	LevelTrace
	LevelDebug
	LevelInfo
	LevelWarn
	LevelError
)

func DefaultLevel

func DefaultLevel() Level

func GetLevel

func GetLevel(name string) Level

func ParseLogLevel

func ParseLogLevel(name string) Level

func ParseLogLevelP

func ParseLogLevelP(name string) (Level, bool)

func (*Level) UnmarshalJSON

func (lvl *Level) UnmarshalJSON(b []byte) error

func (*Level) UnmarshalYAML

func (lvl *Level) UnmarshalYAML(value *yaml.Node) error

type LevelConfig

type LevelConfig struct {
	Pattern string `yaml:"pattern" json:"pattern"`
	Level   Level  `yaml:"level" json:"level"`
}

type Log

type Log interface {
	TraceEnabled() bool
	Trace(string)
	Tracef(fmt string, args ...interface{})
	DebugEnabled() bool
	Debug(string)
	Debugf(fmt string, args ...interface{})
	InfoEnabled() bool
	Info(string)
	Infof(fmt string, args ...interface{})
	WarnEnabled() bool
	Warn(string)
	Warnf(fmt string, args ...interface{})
	ErrorEnabled() bool
	Error(string)
	Errorf(fmt string, args ...interface{})

	Log(level Level, m string)
	Logf(level Level, fmt string, args ...interface{})

	SetLevel(level Level)
	Level() Level
}

func GetLog

func GetLog(name string) Log

func GetLogOpt

func GetLogOpt(name string, opt int) Log

type LogAppender

type LogAppender struct {
	// contains filtered or unexported fields
}

func (*LogAppender) Configure

func (s *LogAppender) Configure(cfg *Config) error

func (*LogAppender) Name

func (s *LogAppender) Name() string

//////////////////////////////////////// BEGIN: implements logging.Logging

func (*LogAppender) Printf

func (s *LogAppender) Printf(format string, v ...interface{})

func (*LogAppender) Write

func (s *LogAppender) Write(p []byte) (n int, err error)

type Logging

type Logging interface {
	Name() string
	Printf(format string, v ...interface{})
	Write(p []byte) (n int, err error)
}

func Configure

func Configure(cfg *Config) Logging

func New

func New(cfg *Config) Logging

func NewLoggingWithDiscard

func NewLoggingWithDiscard(name string) Logging

func NewLoggingWithWriter

func NewLoggingWithWriter(name string, out io.Writer) Logging

func NewWithFilename

func NewWithFilename(name string, filename string, maxSize int, console bool) Logging

func SetDefaultLogging

func SetDefaultLogging(l Logging) Logging

Jump to

Keyboard shortcuts

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