Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Service = dependency.Service{ Dependencies: fx.Provide( NewPrintLogger, fx.Annotated{ Group: "middleware", Target: NewMidlleware, }, ), ConfigFunc: func(set dependency.FlagSet) { set.String("app-name", filepath.Base(os.Args[0]), "The name of the application being configured") set.String("app-version", "dev", "The version of the application being configured") set.String("environment", "test", "The environment that the application is deployed in") set.String("logger", "development", "Whether to log in development mode.") set.StringSlice("excluded-headers", []string{"Authorization"}, "Which headers to hide from the request log") }, Constructor: NewLoggerFactory().Logger, }
Service is the exported variable that can be used by the framework package
Functions ¶
func NewMidlleware ¶
func NewMidlleware(logger *zap.Logger, config dependency.ConfigGetter) mux.MiddlewareFunc
NewMiddleware returns you a new instance of the Logger middleware
Types ¶
type LoggerConstructor ¶
LoggerConstructor is a type that can give you an instance of a logger
type LoggerFactory ¶
type LoggerFactory struct {
LoggerConstructors map[string]LoggerConstructor
}
LoggerFactory is a type that can create instances of loggers
func NewLoggerFactory ¶
func NewLoggerFactory() LoggerFactory
NewLoggerFactory will create a new instance of a logger factory
func (LoggerFactory) Logger ¶
func (f LoggerFactory) Logger(settings dependency.ConfigGetter) (*zap.Logger, error)
Logger creates a new instance of a *zap.Logger
type PrintLogger ¶
PrintLogger implements a generalised logging interface
func NewPrintLogger ¶
func NewPrintLogger(logger *zap.Logger) PrintLogger
NewPrintLogger creates a new instance of the PrintLogger
func (PrintLogger) Println ¶
func (p PrintLogger) Println(arguments ...interface{})
Println prints the arguments to the zap logger
type ResponseLogger ¶
type ResponseLogger struct { http.ResponseWriter Status int }
ResponseLogger is a ResponseWriter that is able to log the status code of the response
func NewResponseLogger ¶
func NewResponseLogger(w http.ResponseWriter) *ResponseLogger
NewResponseLogger returns you an instance of a *ResponseLogger
func (*ResponseLogger) WriteHeader ¶
func (l *ResponseLogger) WriteHeader(statusCode int)
WriteHeader intercepts the call to the base ResponseWriter and logs the status code sent