log

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPHandlerFuncWithLog added in v0.24.0

func HTTPHandlerFuncWithLog(logger Logger, next http.HandlerFunc, middlewareConfig ...APIMiddlewareConfig) http.HandlerFunc

HTTPHandlerFuncWithLog is http handler func with log.

func HTTPHandlerWithLog added in v0.24.0

func HTTPHandlerWithLog(logger Logger, next http.Handler, middlewareConfig ...APIMiddlewareConfig) http.Handler

HTTPHandlerWithLog is http handler with log. Also includes error stack tracing feature if you use it.

func HTTPMiddlewareWithLog added in v0.24.0

func HTTPMiddlewareWithLog(logger Logger, middlewareConfig ...APIMiddlewareConfig) func(http.Handler) http.Handler

HTTPMiddlewareWithLog is http middleware that will log the request and response.

func PubSubHandlerFuncWithLog added in v0.24.0

func PubSubHandlerFuncWithLog(logger Logger, next pubsub.HandlerFunc, middlewareConfig ...PubSubMiddlewareConfig) pubsub.HandlerFunc

PubSubHandlerFuncWithLog is pubsub handler with log. Also includes error stack tracing feature if you use it.

func PubSubMiddlewareWithLog added in v0.24.0

func PubSubMiddlewareWithLog(logger Logger, middlewareConfig ...PubSubMiddlewareConfig) func(pubsub.HandlerFunc) pubsub.HandlerFunc

PubSubMiddlewareWithLog is pubsub middelware that will log the request.

func StreamMiddlewareWithLog added in v0.7.0

func StreamMiddlewareWithLog(logger Logger, middlewareConfig ...APIMiddlewareConfig) grpc.StreamServerInterceptor

StreamMiddlewareWithLog is stream grpc middleware that will log the request and response. Todo: implement logger here.

func UnaryMiddlewareWithLog added in v0.7.0

func UnaryMiddlewareWithLog(logger Logger, middlewareConfig ...APIMiddlewareConfig) grpc.UnaryServerInterceptor

UnaryMiddlewareWithLog is unary grpc middleware that will log the request and response.

Types

type APIMiddlewareConfig added in v0.24.0

type APIMiddlewareConfig struct {
	// Show request header.
	RequestHeader bool
	// Show request body.
	RequestBody bool
	// Show response header.
	ResponseHeader bool
	// Show response body.
	ResponseBody bool
	// Show raw path (includes query params).
	RawPath bool
	// Show error stack.
	Error bool
}

APIMiddlewareConfig is log config for middleware.

type Logger

type Logger interface {
	Trace(format string, args ...interface{})
	Debug(format string, args ...interface{})
	Info(format string, args ...interface{})
	Warn(format string, args ...interface{})
	Error(format string, args ...interface{})
	Fatal(format string, args ...interface{})
	Panic(format string, args ...interface{})

	// General log with key value.
	Log(fields map[string]interface{})
}

Logger is logging interface.

See usage example in example folder.

type PubSubMiddlewareConfig added in v0.24.0

type PubSubMiddlewareConfig struct {
	// Topic/queue name.
	Topic string
	// Show message payload.
	Payload bool
	// Show error stack.
	Error bool
}

PubSubMiddlewareConfig is pubsub config for middleware.

Directories

Path Synopsis
Deprecated: use slog.
Deprecated: use slog.
Package chain is a logger chain.
Package chain is a logger chain.
Package elasticsearch is a wrapper of the original "github.com/elastic/go-elasticsearch".
Package elasticsearch is a wrapper of the original "github.com/elastic/go-elasticsearch".
Package logrus is a wrapper of the original "github.com/sirupsen/logrus" library.
Package logrus is a wrapper of the original "github.com/sirupsen/logrus" library.
Package mock_log is a generated GoMock package.
Package mock_log is a generated GoMock package.
Package newrelic is a wrapper of the original "github.com/newrelic/go-agent/v3/newrelic".
Package newrelic is a wrapper of the original "github.com/newrelic/go-agent/v3/newrelic".
Package nop is no-operation logging.
Package nop is no-operation logging.
Package zap is a wrapper of the original "github.com/uber-go/zap" library.
Package zap is a wrapper of the original "github.com/uber-go/zap" library.
Package zerolog is a wrapper of the original "github.com/rs/zerolog" library.
Package zerolog is a wrapper of the original "github.com/rs/zerolog" library.

Jump to

Keyboard shortcuts

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