logger

package
v0.0.0-...-1513131 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitLogger

func InitLogger()

InitLogger initializes the global logger instance

Types

type LoggerInterface

type LoggerInterface interface {
	InitLogger()
	Debug(ctx context.Context, msg string, fields ...zap.Field)
	Info(ctx context.Context, msg string, fields ...zap.Field)
	Result(ctx context.Context, msg string, fields ...zap.Field)
	Warn(ctx context.Context, msg string, fields ...zap.Field)
	Error(ctx context.Context, msg string, fields ...zap.Field)
	Fatal(ctx context.Context, msg string, fields ...zap.Field)
	SetLogLevel(level string)
	Flush()
}

LoggerInterface defines the methods for a logger

func GetLogger

func GetLogger() LoggerInterface

GetLogger returns the global logger instance

type ZapLogger

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

ZapLogger is the implementation of LoggerInterface using zap

func (*ZapLogger) Debug

func (zl *ZapLogger) Debug(ctx context.Context, msg string, fields ...zap.Field)

Debug logs a message at Debug level with context

func (*ZapLogger) Error

func (zl *ZapLogger) Error(ctx context.Context, msg string, fields ...zap.Field)

Error logs a message at Error level with context

func (*ZapLogger) Fatal

func (zl *ZapLogger) Fatal(ctx context.Context, msg string, fields ...zap.Field)

Fatal logs a message at Fatal level with context

func (*ZapLogger) Flush

func (zl *ZapLogger) Flush()

Flush flushes any buffered log entries

func (*ZapLogger) Info

func (zl *ZapLogger) Info(ctx context.Context, msg string, fields ...zap.Field)

Info logs a message at Info level with context

func (*ZapLogger) InitLogger

func (zl *ZapLogger) InitLogger()

InitLogger initializes the logger with optional file logging

func (*ZapLogger) Result

func (zl *ZapLogger) Result(ctx context.Context, msg string, fields ...zap.Field)

Result logs a message at Info level with context

func (*ZapLogger) SetLogLevel

func (zl *ZapLogger) SetLogLevel(level string)

SetLogLevel dynamically sets the log level

func (*ZapLogger) Warn

func (zl *ZapLogger) Warn(ctx context.Context, msg string, fields ...zap.Field)

Warn logs a message at Warn level with context

Jump to

Keyboard shortcuts

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