Documentation ¶
Index ¶
- func NewAroundLoggingHandler(handler http.Handler, logger Logger) http.Handler
- func NewAroundLoggingMiddleware(logger Logger) func(http.Handler) http.Handler
- func NewLoggingHandler(handler http.Handler, logger Logger) http.Handler
- func NewLoggingMiddleware(logger Logger) func(http.Handler) http.Handler
- type ContextLogger
- type LogRecord
- type Logger
- type LoggingHandler
- type LoggingWriter
- func (r *LoggingWriter) CloseNotify() <-chan bool
- func (r *LoggingWriter) Flush()
- func (r *LoggingWriter) GetCustomLogRecord(key string) string
- func (r *LoggingWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (r *LoggingWriter) Push(target string, opts *http.PushOptions) error
- func (r *LoggingWriter) SetCustomLogRecord(key, value string)
- func (r *LoggingWriter) WrappedWriter() http.ResponseWriter
- func (r *LoggingWriter) Write(p []byte) (int, error)
- func (r *LoggingWriter) WriteHeader(status int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAroundLoggingHandler ¶
Types ¶
type ContextLogger ¶ added in v1.2.0
type LoggingHandler ¶
type LoggingHandler struct {
// contains filtered or unexported fields
}
func (*LoggingHandler) ServeHTTP ¶
func (h *LoggingHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request)
type LoggingWriter ¶
type LoggingWriter struct { http.ResponseWriter // contains filtered or unexported fields }
func GetLoggingWriter ¶ added in v1.1.0
func GetLoggingWriter(ctx context.Context) *LoggingWriter
func (*LoggingWriter) CloseNotify ¶
func (r *LoggingWriter) CloseNotify() <-chan bool
http.CloseNotifier interface
func (*LoggingWriter) GetCustomLogRecord ¶ added in v1.3.0
func (r *LoggingWriter) GetCustomLogRecord(key string) string
w.(accesslogger.LoggingWriter).GetCustomLogRecord("X-User-Id")
func (*LoggingWriter) Hijack ¶
func (r *LoggingWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
func (*LoggingWriter) Push ¶
func (r *LoggingWriter) Push(target string, opts *http.PushOptions) error
http.Pusher
func (*LoggingWriter) SetCustomLogRecord ¶
func (r *LoggingWriter) SetCustomLogRecord(key, value string)
SetCustomLogRecord and GetCustomLogRecord functions provide accessors to the logRecord.CustomRecords. You can use it to store arbitrary strings that are relevant to this request.
Alternative method would be to store the value in context. Which doesn't work when you want to retrieve the value from a HTTP middleware that is earlier in the middleware chain, eg: accesslog, recovery.
w.(accesslogger.LoggingWriter).SetCustomLogRecord("X-User-Id", "3")
func (*LoggingWriter) WrappedWriter ¶ added in v1.1.0
func (r *LoggingWriter) WrappedWriter() http.ResponseWriter
WrapWriter interface
func (*LoggingWriter) WriteHeader ¶
func (r *LoggingWriter) WriteHeader(status int)
Click to show internal directories.
Click to hide internal directories.