logger

package
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 16 Imported by: 22

Documentation

Index

Constants

View Source
const (
	SourceFileName = "file"
	SourceLineName = "name"
	SourceFuncName = "func"
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

func Debugf

func Debugf(format string, args ...interface{})

func Debugln

func Debugln(args ...interface{})

func EnableFnTrace

func EnableFnTrace()

func Error

func Error(args ...interface{})

func Errorf

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

func Errorln

func Errorln(args ...interface{})

func Fatal

func Fatal(args ...interface{})

func Fatalf

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

func Fatalln

func Fatalln(args ...interface{})

func GetLevel

func GetLevel() string

func GetLogger

func GetLogger(ctx context.Context, pkg, fnName string) *logrus.Entry

func Info

func Info(args ...interface{})

func Infof

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

func Infoln

func Infoln(args ...interface{})

func LogInit

func LogInit()

func MarshalStack

func MarshalStack(err error) interface{}

func New

func New(serviceName, serviceVersion string) *logrus.Entry

New create logger instance with request_id as a field also set the default format to JSON.

func Print

func Print(args ...interface{})

func Printf

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

func Println

func Println(args ...interface{})

func Request

func Request(next http.Handler) http.Handler

func SetFormatter

func SetFormatter(formatter logrus.Formatter)

func SetLevel

func SetLevel(level string)

func SetupLogs added in v0.0.36

func SetupLogs(logFile ...string)

SetupLogs adds hooks to send logs to different destinations depending on level

func Warn

func Warn(args ...interface{})

func Warnf

func Warnf(format string, args ...interface{})

func Warnln

func Warnln(args ...interface{})

func WithContext

func WithContext(ctx context.Context) *logrus.Entry

func WithErrorContext

func WithErrorContext(ctx context.Context, err error) *logrus.Entry

func WithFields

func WithFields(fields Fields) *logrus.Entry

func WithRequest

func WithRequest(ctx context.Context, req *http.Request) context.Context

func WithStack

func WithStack(err error) *logrus.Entry

Types

type DailyFileWriter added in v0.0.36

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

func NewDailyFileWriter added in v0.0.36

func NewDailyFileWriter(basePath string) (*DailyFileWriter, error)

func (*DailyFileWriter) Write added in v0.0.36

func (w *DailyFileWriter) Write(p []byte) (int, error)

type Fields

type Fields logrus.Fields

type WriterHook

type WriterHook struct {
	Writer    io.Writer
	LogLevels []logrus.Level
}

WriterHook is a hook that writes logs of specified LogLevels to specified Writer

func (*WriterHook) Fire

func (hook *WriterHook) Fire(entry *logrus.Entry) error

Fire will be called when some logging function is called with current hook It will format log entry to string and write it to appropriate writer

func (*WriterHook) Levels

func (hook *WriterHook) Levels() []logrus.Level

Levels define on which log levels this hook would trigger

Jump to

Keyboard shortcuts

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