logger

package
v0.0.0-...-8be1149 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger() *zap.Logger

Logger returns the initialized zap logger.

func NewLogger

func NewLogger() (*zap.SugaredLogger, *zap.Logger, error)

NewLogger initializes the logger and returns a sugared logger.

func SetKafkaBrokers

func SetKafkaBrokers(kafkaBrokers string)

SetKafkaBrokers sets the Kafka brokers.

func SetKafkaTopic

func SetKafkaTopic(kafkaTopic string)

SetKafkaTopic sets the Kafka topic.

func SetLogLevel

func SetLogLevel(logLevel LogLevel)

SetLogLevel sets the log level.

func SetLogPath

func SetLogPath(logPath string)

SetLogPath sets the log path.

func SetMaxAge

func SetMaxAge(maxAge int)

SetMaxAge sets the maximum age of a log file.

func SetMaxBackups

func SetMaxBackups(maxBackups int)

SetMaxBackups sets the maximum number of backup log files.

func SetMaxSize

func SetMaxSize(maxSize int)

SetMaxSize sets the maximum size of a log file.

func SetMode

func SetMode(mode string)

SetMode sets the log mode.

func SetOutput

func SetOutput(output string)

SetOutput sets the log output.

func SugaredLogger

func SugaredLogger() *zap.SugaredLogger

SugaredLogger returns the initialized sugared logger.

Types

type Config

type Config struct {
	LogPath      string
	MaxSize      int
	MaxBackups   int
	MaxAge       int
	LogLevel     LogLevel
	Output       string
	Mode         string
	KafkaBrokers string
	KafkaTopic   string
}

Config holds logger configuration options.

type Log

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

func NewLog

func NewLog(zaplog *zap.Logger) *Log

func (*Log) Close

func (l *Log) Close() error

func (*Log) Log

func (l *Log) Log(level log.Level, values ...interface{}) error

func (*Log) Sync

func (l *Log) Sync() error

type LogLevel

type LogLevel int8

LogLevel defines the severity of a logger internal.

const (
	// DebugLevel logs debug messages.
	DebugLevel LogLevel = iota - 1
	// InfoLevel logs informational messages.
	InfoLevel
	// WarnLevel logs warning messages.
	WarnLevel
	// ErrorLevel logs error messages.
	ErrorLevel
	FatalLevel
)

type Option

type Option func(*Log)

func WithMessageKey

func WithMessageKey(msgKey string) Option

Jump to

Keyboard shortcuts

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