log

package
v0.0.43 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitFromConfig

func InitFromConfig(
	loggerPrefixName, moduleName string,
	logLevel int,
	isStdout bool,
	isJson bool,
	logLocation string,
	rotateCount uint,
	rotationTime uint,
) error

InitFromConfig initializes a Zap-based logger.

func ZDebug

func ZDebug(ctx context.Context, msg string, keysAndValues ...any)

func ZError

func ZError(ctx context.Context, msg string, err error, keysAndValues ...any)

func ZInfo

func ZInfo(ctx context.Context, msg string, keysAndValues ...any)

func ZWarn

func ZWarn(ctx context.Context, msg string, err error, keysAndValues ...any)

Types

type Color

type Color uint8

Color represents a text color.

const (
	Black Color = iota + 30
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	White
)

Foreground colors.

func (Color) Add

func (c Color) Add(s string) string

Add adds the coloring to the given string.

type Logger

type Logger interface {
	Debug(ctx context.Context, msg string, keysAndValues ...any)
	Info(ctx context.Context, msg string, keysAndValues ...any)
	Warn(ctx context.Context, msg string, err error, keysAndValues ...any)
	Error(ctx context.Context, msg string, err error, keysAndValues ...any)
	WithValues(keysAndValues ...any) Logger
	WithName(name string) Logger
	WithCallDepth(depth int) Logger
}

type ZapLogger

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

func NewZapLogger

func NewZapLogger(
	loggerPrefixName, loggerName string,
	logLevel int,
	isStdout bool,
	isJson bool,
	logLocation string,
	rotateCount uint,
	rotationTime uint,
) (*ZapLogger, error)

func (*ZapLogger) Debug

func (l *ZapLogger) Debug(ctx context.Context, msg string, keysAndValues ...any)

func (*ZapLogger) Error

func (l *ZapLogger) Error(ctx context.Context, msg string, err error, keysAndValues ...any)

func (*ZapLogger) Info

func (l *ZapLogger) Info(ctx context.Context, msg string, keysAndValues ...any)

func (*ZapLogger) ToZap

func (l *ZapLogger) ToZap() *zap.SugaredLogger

func (*ZapLogger) Warn

func (l *ZapLogger) Warn(ctx context.Context, msg string, err error, keysAndValues ...any)

func (*ZapLogger) WithCallDepth

func (l *ZapLogger) WithCallDepth(depth int) Logger

func (*ZapLogger) WithName

func (l *ZapLogger) WithName(name string) Logger

func (*ZapLogger) WithValues

func (l *ZapLogger) WithValues(keysAndValues ...any) Logger

Jump to

Keyboard shortcuts

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