Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var LogDecision = map[string]Decision{ "NoLogCall": NoLogCall, "LogFinishCall": LogFinishCall, "LogStartAndFinishCall": LogStartAndFinishCall, }
LogDecision defines mapping of flag options to the logging decision.
Functions ¶
func DefaultCodeToLevel ¶
DefaultCodeToLevel is the helper mapper that maps HTTP Response codes to log levels.
func DefaultErrorToCode ¶
Types ¶
type CodeToLevel ¶
CodeToLevel function defines the mapping between HTTP Response codes to log levels for server side.
type Decider ¶
type Decider func() Decision
Decider function defines rules for suppressing the logging. TODO : Add the method name as a parameter in case we want to log based on method names.
type Decision ¶
type Decision int
Decision defines rules for enabling start and end of logging.
func DefaultDeciderMethod ¶
func DefaultDeciderMethod() Decision
DefaultDeciderMethod is the default implementation of decider to see if you should log the call by default this is set to LogStartAndFinishCall.
type DurationToFields ¶
DurationToFields function defines how to produce duration fields for logging.
type ErrorToCode ¶
ErrorToCode function determines the error code of the error for the http response.
type Fields ¶
type Fields []string
Fields represents logging fields. It has to have even number of elements (pairs).
func DurationToTimeMillisFields ¶
DurationToTimeMillisFields converts the duration to milliseconds and uses the key `http.time_ms`.
type HTTPServerMiddleware ¶
type HTTPServerMiddleware struct {
// contains filtered or unexported fields
}
func NewHTTPServerMiddleware ¶
func NewHTTPServerMiddleware(logger log.Logger, opts ...Option) *HTTPServerMiddleware
func (*HTTPServerMiddleware) HTTPMiddleware ¶
func (m *HTTPServerMiddleware) HTTPMiddleware(name string, next http.Handler) http.HandlerFunc
type Option ¶
type Option func(*options)
Types for the Options.
func WithDecider ¶
WithDecider customizes the function for deciding if the HTTP Middlewares/Tripperwares should log.
func WithLevels ¶
func WithLevels(f CodeToLevel) Option
WithLevels customizes the function for mapping HTTP response codes and interceptor log level statements.