log

package
v0.0.0-...-7893bb9 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogModeOff     = "off"
	LogModeConsole = "console"
	LogModeFile    = "file"
)
View Source
const (
	LogTrace = 0
	LogDebug = 1
	LogInfo  = 2
	LogError = 3
	LogOff   = 4
)

Variables

View Source
var LevelMap = map[string]int{
	"trace": LogTrace,
	"debug": LogDebug,
	"info":  LogInfo,
	"error": LogError,
	"off":   LogOff,
}

Functions

func ApplyConfig

func ApplyConfig(logConfig ILogConfig) error

func InitLogger

func InitLogger(logMode, logPath string) (err error)

func Now

func Now() string

func SetLogger

func SetLogger(logger ILogger)

Types

type FileLogger

type FileLogger struct {
	Out   io.WriteCloser
	Level int
}

func (*FileLogger) Close

func (l *FileLogger) Close() error

func (*FileLogger) Debug

func (l *FileLogger) Debug(params ...interface{})

func (*FileLogger) Debugf

func (l *FileLogger) Debugf(format string, params ...interface{})

func (*FileLogger) Error

func (l *FileLogger) Error(params ...interface{})

func (*FileLogger) Errorf

func (l *FileLogger) Errorf(format string, params ...interface{})

func (*FileLogger) Info

func (l *FileLogger) Info(params ...interface{})

func (*FileLogger) Infof

func (l *FileLogger) Infof(format string, params ...interface{})

func (*FileLogger) SetLevel

func (l *FileLogger) SetLevel(level int)

func (*FileLogger) Trace

func (l *FileLogger) Trace(params ...interface{})

func (*FileLogger) Tracef

func (l *FileLogger) Tracef(format string, params ...interface{})

type ILogConfig

type ILogConfig interface {
	GetLogLevel() string
}

type ILogger

type ILogger interface {
	SetLevel(int)
	Trace(...interface{})
	Debug(...interface{})
	Info(...interface{})
	Error(...interface{})
	Tracef(string, ...interface{})
	Debugf(string, ...interface{})
	Infof(string, ...interface{})
	Errorf(string, ...interface{})
	Close() error
}
var Logger ILogger = &StdLogger{Level: LogDebug}

func NewFileLogger

func NewFileLogger(filePath string, level, multiSize int) (ILogger, error)

func NewSkipLogger

func NewSkipLogger() (ILogger, error)

func NewStdLogger

func NewStdLogger(level int) (ILogger, error)

type LogFile

type LogFile struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*LogFile) Close

func (l *LogFile) Close() error

func (*LogFile) Create

func (l *LogFile) Create() error

func (*LogFile) Write

func (l *LogFile) Write(b []byte) (int, error)

type SkipLogger

type SkipLogger struct{}

func (*SkipLogger) Close

func (s *SkipLogger) Close() error

func (*SkipLogger) Debug

func (s *SkipLogger) Debug(params ...interface{})

func (*SkipLogger) Debugf

func (s *SkipLogger) Debugf(fromat string, params ...interface{})

func (*SkipLogger) Error

func (s *SkipLogger) Error(params ...interface{})

func (*SkipLogger) Errorf

func (s *SkipLogger) Errorf(fromat string, params ...interface{})

func (*SkipLogger) Info

func (s *SkipLogger) Info(params ...interface{})

func (*SkipLogger) Infof

func (s *SkipLogger) Infof(fromat string, params ...interface{})

func (*SkipLogger) SetLevel

func (s *SkipLogger) SetLevel(level int)

func (*SkipLogger) Trace

func (s *SkipLogger) Trace(params ...interface{})

func (*SkipLogger) Tracef

func (s *SkipLogger) Tracef(fromat string, params ...interface{})

type StdLogger

type StdLogger struct {
	Level int
}

func (*StdLogger) Close

func (s *StdLogger) Close() error

func (*StdLogger) Debug

func (s *StdLogger) Debug(params ...interface{})

func (*StdLogger) Debugf

func (s *StdLogger) Debugf(fromat string, params ...interface{})

func (*StdLogger) Error

func (s *StdLogger) Error(params ...interface{})

func (*StdLogger) Errorf

func (s *StdLogger) Errorf(fromat string, params ...interface{})

func (*StdLogger) Info

func (s *StdLogger) Info(params ...interface{})

func (*StdLogger) Infof

func (s *StdLogger) Infof(fromat string, params ...interface{})

func (*StdLogger) SetLevel

func (s *StdLogger) SetLevel(level int)

func (*StdLogger) Trace

func (s *StdLogger) Trace(params ...interface{})

func (*StdLogger) Tracef

func (s *StdLogger) Tracef(fromat string, params ...interface{})

Jump to

Keyboard shortcuts

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