elog

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	LOG_DIR = "./log"

	NULL_AUTO_CLEAR_HOURS = 0
	AUTO_CLEAR_HOURS      = 1
)

Variables

View Source
var (
	ErrLogPrefixNil   = errors.New("log Prefix is nil")
	ErrLogTypeIllegal = errors.New("log Type Illegal")
)

Functions

func NewDefaultLogger

func NewDefaultLogger(lc *LogConfig) (*defaultLogger, error)

NewDefaultLogger function returns a `Logger` object. We need put in logger config.

func NewSingleLogger

func NewSingleLogger(lc *LogConfig) error

Types

type LogConfig

type LogConfig struct {
	LogTyp         string
	Prefix         string
	Dir            string
	AutoClearHours int
	Depth          int
	LogMaxByteNum  int64
	LogLevel       LogLevel
	Format         LogFormat
}

type LogFormat

type LogFormat string
const (
	FORMAT_JSON   LogFormat = "json"
	FORMAT_NORMAL LogFormat = "normal"
)

type LogLevel

type LogLevel int32
const (
	TRACE LogLevel = iota
	DEBUG
	INFO
	WARNING
	ERROR
	FATAL
)

type Logger

type Logger interface {
	DebugfCtx(ctx context.Context, f string, args ...interface{})
	InfofCtx(ctx context.Context, f string, args ...interface{})
	WarnfCtx(ctx context.Context, f string, args ...interface{})
	ErrorfCtx(ctx context.Context, f string, args ...interface{})

	Printf(f string, args ...interface{})
	Debugf(f string, args ...interface{})
	Errorf(f string, args ...interface{})
	Infof(f string, args ...interface{})
	Warnf(f string, args ...interface{})

	Debug(msg string)
	Error(msg string)
	Info(msg string)
	Warn(msg string)
}
var Elog Logger

func NewLogger

func NewLogger(lc *LogConfig) (Logger, error)

Jump to

Keyboard shortcuts

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