log

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimestampFieldNameDefault = "t"
	MessageFieldNameDefault   = "msg"
)

Variables

This section is empty.

Functions

func ClientLoggerUnaryInterceptor added in v0.0.9

func ClientLoggerUnaryInterceptor(from, to string) grpc.UnaryClientInterceptor

ClientLoggerUnaryInterceptor returns a new unary client interceptor for log from what to

func InitLog

func InitLog(out io.Writer, isProd bool)

InitLog initializes zerolog for this service you need provide stdout for your log this function will init default logger with default formatter and default hook

func SetDefaultDevLogger added in v0.1.0

func SetDefaultDevLogger(w io.Writer)

func SetDefaultProductionLogger added in v0.1.0

func SetDefaultProductionLogger(w io.Writer)

Types

type GRPCServerMWHook added in v0.1.0

type GRPCServerMWHook struct{}

GRPCServerMWHook will add req-id and handler name to your log

func (GRPCServerMWHook) Run added in v0.1.0

type TestLogger added in v0.2.0

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

func NewTestLogger added in v0.2.0

func NewTestLogger(opts ...TestLoggerOps) *TestLogger

NewTestLogger returns new instance of TestLogger you need provide stdout for your log this function will init default logger with default formatter

as default TestLogger use Info level

as default TestLogger use os.Stdout

as default TestLogger use "unknown" as test name

func (*TestLogger) Printf added in v0.2.0

func (t *TestLogger) Printf(format string, v ...any)

type TestLoggerOps added in v0.2.0

type TestLoggerOps func(t *TestLogger)

func WithTestLoggerLevel added in v0.2.0

func WithTestLoggerLevel(lvl zerolog.Level) TestLoggerOps

WithTestLoggerLevel use for set custom level for TestLogger as level use zerolog.Level

func WithTestLoggerName added in v0.2.0

func WithTestLoggerName(name string) TestLoggerOps

WithTestLoggerName use for set custom name for TestLogger as name use string

func WithTestLoggerWriter added in v0.2.0

func WithTestLoggerWriter(w io.Writer) TestLoggerOps

WithTestLoggerWriter use for set custom writer for TestLogger

Jump to

Keyboard shortcuts

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