plog

package
v1.1.39 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: MIT Imports: 13 Imported by: 13

README

plog

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debugc

func Debugc(ctx context.Context, msg string, v ...any)

func Debugf

func Debugf(msg string, v ...any)

func Enable

func Enable(l level.Level)

func EnableLogToFile

func EnableLogToFile(jackLog *LogConfig)

func Errorc

func Errorc(ctx context.Context, msg string, v ...any)

func Errorf

func Errorf(msg string, v ...any)

func Fatalc added in v1.0.25

func Fatalc(ctx context.Context, msg string, v ...any)

func Fatalf

func Fatalf(msg string, v ...any)

func GetFuncName

func GetFuncName(i interface{}) string

func GetStructName

func GetStructName(i any) string

func Infoc

func Infoc(ctx context.Context, msg string, v ...any)

func Infof

func Infof(msg string, v ...any)

func IsDebug

func IsDebug() bool

func Jsonify

func Jsonify(v any) string

func JsonifyNoIndent

func JsonifyNoIndent(v interface{}) string

func PanicError

func PanicError(err error, v ...any)

func SetLogger

func SetLogger(l Logger)

func SetOutput

func SetOutput(w io.Writer)

func SetSlog added in v1.0.13

func SetSlog()

func TimeDurationDefer

func TimeDurationDefer(prefix ...string) func()

func TimeFuncDuration

func TimeFuncDuration() func() time.Duration

TimeFuncDuration returns the duration consumed by function. It has specified usage like:

    f := TimeFuncDuration()
	   DoSomething()
	   duration := f()

func Warnc

func Warnc(ctx context.Context, msg string, v ...any)

func Warnf

func Warnf(msg string, v ...any)

func With

func With(c context.Context, msg string, v ...any) context.Context

With used to store some data in log-ctx Ie supports two forms of writing 1. With(log-ctx, "group") When only msg has a value, it is used as a group 2. With(log-ctx, "key1", "value1") or With(log-ctx, "key1", "value1", "key2", "value2") When msg and v both have values, With resolves them into key-value pairs The parsed results are stored in the LogContext for use by the Logger

func WithLogger

func WithLogger(c context.Context, w io.Writer) context.Context

Types

type ContextLogger

type ContextLogger interface {
	Infoc(context.Context, string, ...any)
	Debugc(context.Context, string, ...any)
	Warnc(context.Context, string, ...any)
	Errorc(context.Context, string, ...any)
	Fatalc(context.Context, string, ...any)
}

type FormatLogger added in v1.0.25

type FormatLogger interface {
	Infof(string, ...any)
	Debugf(string, ...any)
	Warnf(string, ...any)
	Errorf(string, ...any)
	Fatalf(string, ...any)
}

type LogConfig

type LogConfig lumberjack.Logger

func (*LogConfig) SetDefault

func (l *LogConfig) SetDefault()

func (*LogConfig) Write

func (l *LogConfig) Write(p []byte) (n int, err error)

type Logger

type Logger interface {
	ContextLogger
	FormatLogger
	PanicError(error, ...any)
	// contains filtered or unexported methods
}

func GetLogger added in v1.1.37

func GetLogger() Logger

Directories

Path Synopsis
log

Jump to

Keyboard shortcuts

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