Documentation ¶
Index ¶
- Variables
- func HandlerFuncWithLog(logger Logger, next http.HandlerFunc, middlewareConfig ...MiddlewareConfig) http.HandlerFunc
- func HandlerWithLog(logger Logger, next http.Handler, middlewareConfig ...MiddlewareConfig) http.Handler
- func MiddlewareWithLog(logger Logger, middlewareConfig ...MiddlewareConfig) func(http.Handler) http.Handler
- func StreamMiddlewareWithLog(logger Logger, middlewareConfig ...MiddlewareConfig) grpc.StreamServerInterceptor
- func UnaryMiddlewareWithLog(logger Logger, middlewareConfig ...MiddlewareConfig) grpc.UnaryServerInterceptor
- type Config
- type LogLevel
- type LogType
- type Logger
- type MiddlewareConfig
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidLogType = errors.New("invalid log type")
ErrInvalidLogType is error for invalid log type.
Functions ¶
func HandlerFuncWithLog ¶
func HandlerFuncWithLog(logger Logger, next http.HandlerFunc, middlewareConfig ...MiddlewareConfig) http.HandlerFunc
HandlerFuncWithLog is http handler func with log.
func HandlerWithLog ¶
func HandlerWithLog(logger Logger, next http.Handler, middlewareConfig ...MiddlewareConfig) http.Handler
HandlerWithLog is http handler with log. Also includes error stack tracing feature if you use it.
func MiddlewareWithLog ¶
func MiddlewareWithLog(logger Logger, middlewareConfig ...MiddlewareConfig) func(http.Handler) http.Handler
MiddlewareWithLog is http middleware that will log the request and response.
func StreamMiddlewareWithLog ¶ added in v0.7.0
func StreamMiddlewareWithLog(logger Logger, middlewareConfig ...MiddlewareConfig) 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 ...MiddlewareConfig) grpc.UnaryServerInterceptor
UnaryMiddlewareWithLog is unary grpc middleware that will log the request and response.
Types ¶
type Config ¶ added in v0.9.0
type Config struct { Type LogType Level LogLevel JsonFormat bool Color bool // For elasticsearch. ElasticsearchAddresses []string ElasticsearchUser string ElasticsearchPassword string ElasticsearchIndex string ElasticsearchIsSync bool }
Config is log config.
type LogLevel ¶
type LogLevel int8
LogLevel is level of log that will be printed. Will print level that is higher than your chosen one.
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 MiddlewareConfig ¶
type MiddlewareConfig 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 }
MiddlewareConfig is log config for middleware.
Directories ¶
Path | Synopsis |
---|---|
Package builtin is a wrapper of the built-in log package.
|
Package builtin is a wrapper of the built-in log package. |
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 nolog is just a mock of logging which do nothing.
|
Package nolog is just a mock of logging which do nothing. |
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. |