ddlog

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: Apache-2.0, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//LogTypeStdout :Log Type Stdout
	LogTypeStdout = "stdout"
	//LogTypeFile :Log Type File
	LogTypeFile = "file"
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

func Debugf

func Debugf(ctx context.Context, tag string, format string, args ...interface{})

func Error

func Error(args ...interface{})

func Errorf

func Errorf(ctx context.Context, tag string, format string, args ...interface{})

func Fatal

func Fatal(args ...interface{})

func Fatalf

func Fatalf(ctx context.Context, tag string, format string, args ...interface{})

func Info

func Info(args ...interface{})

func Infof

func Infof(ctx context.Context, tag string, format string, args ...interface{})

func NewWriter

func NewWriter(config *FileConfig) (zerolog.LevelWriter, error)

func Warn

func Warn(args ...interface{})

func Warnf

func Warnf(ctx context.Context, tag string, format string, args ...interface{})

Types

type DiLogHandle

type DiLogHandle struct {
	zerolog.Logger
	CtxFormatFunc func(ctx context.Context) string
}
var (
	//Logger is defualt log ,and print to stdout, if want format context, use RegisterContextFormat
	Logger *DiLogHandle
)

func NewLoggerWithCfg

func NewLoggerWithCfg(config *FileConfig) (*DiLogHandle, error)

func (*DiLogHandle) Debug

func (zlog *DiLogHandle) Debug(args ...interface{})

func (*DiLogHandle) Debugf

func (zlog *DiLogHandle) Debugf(ctx context.Context, tag string, format string, args ...interface{})

func (*DiLogHandle) Error

func (zlog *DiLogHandle) Error(args ...interface{})

func (*DiLogHandle) Errorf

func (zlog *DiLogHandle) Errorf(ctx context.Context, tag string, format string, args ...interface{})

func (*DiLogHandle) Fatal

func (zlog *DiLogHandle) Fatal(args ...interface{})

func (*DiLogHandle) Fatalf

func (zlog *DiLogHandle) Fatalf(ctx context.Context, tag string, format string, args ...interface{})

func (*DiLogHandle) Info

func (zlog *DiLogHandle) Info(args ...interface{})

func (*DiLogHandle) Infof

func (zlog *DiLogHandle) Infof(ctx context.Context, tag string, format string, args ...interface{})

func (*DiLogHandle) RegisterContextFormat

func (zlog *DiLogHandle) RegisterContextFormat(ctxFmt func(ctx context.Context) string)

func (*DiLogHandle) Warn

func (zlog *DiLogHandle) Warn(args ...interface{})

func (*DiLogHandle) Warnf

func (zlog *DiLogHandle) Warnf(ctx context.Context, tag string, format string, args ...interface{})

type FileConfig

type FileConfig struct {
	//auto clear the log
	AutoClear bool

	//separate will  write wf log
	Separate bool

	//file directory
	FileDir string

	//file prefix name
	FilePrefix string

	//clear hours
	ClearHours int32

	//clear steps
	ClearStep int32

	//is Disable link
	DisableLink bool

	// log level
	Level string

	// logtype is file or stdout
	LogType string
}

type ICtxKey

type ICtxKey interface {
	GetCtxKey() interface{}
}

type PubLog

type PubLog struct {
	zerolog.Logger
	ICtxKey
}

func NewPubLogger

func NewPubLogger(config *FileConfig) (*PubLog, error)

func (*PubLog) Public

func (plog *PubLog) Public(ctx context.Context, key string, pairs map[string]interface{})

func (*PubLog) PublicString

func (plog *PubLog) PublicString(public string)

PublicString will log string directly

Jump to

Keyboard shortcuts

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