log

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

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const LogFileMode = 0666
View Source
const LogTraceIDField = "trace_id"

Variables

This section is empty.

Functions

func HTTPAddLoggerToContextMiddleware

func HTTPAddLoggerToContextMiddleware() func(next http.Handler) http.Handler

HTTPAddLoggerToContextMiddleware HTTP Middleware that will add request logger to request context.

func NewStructuredLogger

func NewStructuredLogger(
	logger Logger,
	getTraceID func(r *http.Request) string,
) func(next http.Handler) http.Handler

NewStructuredLogger Generate a new structured logger.

func SetLoggerInContext

func SetLoggerInContext(ctx context.Context, logger Logger) context.Context

Types

type CorsLogger

type CorsLogger interface {
	Printf(msg string, args ...interface{})
}

type Logger

type Logger interface {
	Configure(level string, format string, filePath string) error

	WithField(key string, value interface{}) Logger
	WithFields(fields map[string]interface{}) Logger
	WithError(err error) Logger

	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Printf(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Panicf(format string, args ...interface{})

	Debug(args ...interface{})
	Info(args ...interface{})
	Print(args ...interface{})
	Warn(args ...interface{})
	Warning(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
	Panic(args ...interface{})

	Debugln(args ...interface{})
	Infoln(args ...interface{})
	Println(args ...interface{})
	Warnln(args ...interface{})
	Warningln(args ...interface{})
	Errorln(args ...interface{})
	Fatalln(args ...interface{})
	Panicln(args ...interface{})

	GetTracingLogger() TracingLogger
	GetCorsLogger() CorsLogger
}

func GetLoggerFromContext

func GetLoggerFromContext(ctx context.Context) Logger

func NewLogger

func NewLogger() Logger

type StructuredLogger

type StructuredLogger struct {
	Logger     Logger
	GetTraceID func(r *http.Request) string
}

StructuredLogger structured logger.

func (*StructuredLogger) NewLogEntry

func (l *StructuredLogger) NewLogEntry(r *http.Request) middleware.LogEntry

NewLogEntry new log entry.

type StructuredLoggerEntry

type StructuredLoggerEntry struct {
	Logger Logger
}

StructuredLoggerEntry Structured logger entry.

func (*StructuredLoggerEntry) Panic

func (l *StructuredLoggerEntry) Panic(v interface{}, stack []byte)

Panic panic log.

func (*StructuredLoggerEntry) Write

func (l *StructuredLoggerEntry) Write(status, bytes int, _ http.Header, elapsed time.Duration, _ interface{})

Write Write.

type TracingLogger

type TracingLogger interface {
	Error(msg string)
	Infof(msg string, args ...interface{})
	Debugf(msg string, args ...interface{})
}

Jump to

Keyboard shortcuts

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