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
- type LogLevel
- type LogType
- type Logger
- type MiddlewareConfig
Constants ¶
This section is empty.
Variables ¶
View Source
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.
Types ¶
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 // Include query param in url path. QueryParam 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 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 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. |
Click to show internal directories.
Click to hide internal directories.