Documentation ¶
Index ¶
- Variables
- func CombinedLoggingHandler(out io.Writer, h http.Handler) http.Handler
- func CustomLoggingHandler(out io.Writer, h http.Handler, f LogFormatter) http.Handler
- func LoggingHandler(out io.Writer, h http.Handler) http.Handler
- func RunServer(ctx context.Context, g *errgroup.Group, config cfg.Config) error
- type LogFormatter
- type LogFormatterParams
Constants ¶
This section is empty.
Variables ¶
var BlocklistMirrorAccessLogFilePath = "crowdsec-blocklist-mirror_access.log"
var RouteHits = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "blocklist_requests_total", Help: "Number of calls to each blocklist", }, []string{"route"}, )
Functions ¶
func CombinedLoggingHandler ¶
CombinedLoggingHandler return a http.Handler that wraps h and logs requests to out in Apache Combined Log Format.
See http://httpd.apache.org/docs/2.2/logs.html#combined for a description of this format.
LoggingHandler always sets the ident field of the log to -
func CustomLoggingHandler ¶
CustomLoggingHandler provides a way to supply a custom log formatter while taking advantage of the mechanisms in this package
func LoggingHandler ¶
LoggingHandler return a http.Handler that wraps h and logs requests to out in Apache Common Log Format (CLF).
See http://httpd.apache.org/docs/2.2/logs.html#common for a description of this format.
LoggingHandler always sets the ident field of the log to -
Example:
r := mux.NewRouter() r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("This is a catch-all route")) }) loggedRouter := handlers.LoggingHandler(os.Stdout, r) http.ListenAndServe(":1123", loggedRouter)
Types ¶
type LogFormatter ¶
type LogFormatter func(writer io.Writer, params LogFormatterParams)
LogFormatter gives the signature of the formatter function passed to CustomLoggingHandler