logger

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 12

README

logger - Normalize various logger interfaces to zerolog.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(logOutput Writer, errorOutput ErrWriter, cfg *Config) (*zerolog.Logger, error)

NewLogger returns a new logger.

func NewSTDLogger

func NewSTDLogger(logger *zerolog.Logger) *log.Logger

NewSTDLogger creates a standard logger that writes to a zerolog logger.

func TestLogger

func TestLogger(logOutput io.Writer) *zerolog.Logger

TestLogger creates a logger useful for unit tests it has a trace level.

Types

type Config

type Config struct {
	Prod           bool          `json:"prod"`
	LogLevelParsed zerolog.Level `json:"-"`
	LogLevel       string        `json:"log_level"`
	GrpcLogLevel   string        `json:"grpc_log_level"`
}

Config represents logging configuration.

func (*Config) ParseLogLevel

func (c *Config) ParseLogLevel(defaultLevel zerolog.Level) error

ParseLogLevel parses the log level in the config and sets the appropriate value for `LogLevelParsed`.

type ErrWriter

type ErrWriter io.Writer

type GRPCZeroLogger

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

GRPCZeroLogger is a GRPC logger that uses zerolog.

func NewGRPCZeroLogger

func NewGRPCZeroLogger(log *zerolog.Logger, level zerolog.Level) GRPCZeroLogger

NewGRPCZeroLogger creates a GRPCZeroLogger.

func (GRPCZeroLogger) Error

func (l GRPCZeroLogger) Error(args ...interface{})

Error logs an error message.

func (GRPCZeroLogger) Errorf

func (l GRPCZeroLogger) Errorf(format string, args ...interface{})

Errorf formats and logs an error message.

func (GRPCZeroLogger) Errorln

func (l GRPCZeroLogger) Errorln(args ...interface{})

Errorln logs an error message and a newline.

func (GRPCZeroLogger) Fatal

func (l GRPCZeroLogger) Fatal(args ...interface{})

Fatal logs a fatal message.

func (GRPCZeroLogger) Fatalf

func (l GRPCZeroLogger) Fatalf(format string, args ...interface{})

Fatalf formats and logs a fatal message.

func (GRPCZeroLogger) Fatalln

func (l GRPCZeroLogger) Fatalln(args ...interface{})

Fatalln logs a fatal message and a newline.

func (GRPCZeroLogger) Info

func (l GRPCZeroLogger) Info(args ...interface{})

Info logs an info message.

func (GRPCZeroLogger) Infof

func (l GRPCZeroLogger) Infof(format string, args ...interface{})

Infof formats and logs an info message.

func (GRPCZeroLogger) Infoln

func (l GRPCZeroLogger) Infoln(args ...interface{})

Infoln formats and logs an info message and a newline.

func (GRPCZeroLogger) Print

func (l GRPCZeroLogger) Print(args ...interface{})

Print prints a message.

func (GRPCZeroLogger) Printf

func (l GRPCZeroLogger) Printf(format string, args ...interface{})

Printf formats and prints a message.

func (GRPCZeroLogger) Println

func (l GRPCZeroLogger) Println(args ...interface{})

Println prints a message and a newline.

func (GRPCZeroLogger) V

func (l GRPCZeroLogger) V(_ int) bool

V always returns true.

func (GRPCZeroLogger) Warning

func (l GRPCZeroLogger) Warning(args ...interface{})

Warning logs a warning message.

func (GRPCZeroLogger) Warningf

func (l GRPCZeroLogger) Warningf(format string, args ...interface{})

Warningf formats and logs a warning message.

func (GRPCZeroLogger) Warningln

func (l GRPCZeroLogger) Warningln(args ...interface{})

Warningln formats and logs a warning message and a newline.

type LevelWriter

type LevelWriter struct {
	io.Writer
	ErrorWriter io.Writer
}

func (*LevelWriter) WriteLevel

func (lw *LevelWriter) WriteLevel(l zerolog.Level, p []byte) (n int, err error)

type Writer

type Writer io.Writer

type ZerologWriter

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

ZerologWriter implements io.Writer for a zerolog logger.

func NewZerologWriter

func NewZerologWriter(logger *zerolog.Logger) *ZerologWriter

NewZerologWriter creates a new ZerologWriter.

func NewZerologWriterWithLevel

func NewZerologWriterWithLevel(logger *zerolog.Logger, level zerolog.Level) *ZerologWriter

func (*ZerologWriter) Write

func (z *ZerologWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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