Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrorKey = logrus.ErrorKey
ErrorKey defines the key used to log errors.
Functions ¶
Types ¶
type CommonLogFormat ¶
type CommonLogFormat struct{}
CommonLogFormat implements the logrus.Formatter interface it writes logrus entries using a CLF format prepended by the request-id.
func (*CommonLogFormat) Format ¶
func (f *CommonLogFormat) Format(entry *logrus.Entry) ([]byte, error)
Format implements the logrus.Formatter interface. It returns the given logrus entry as a CLF line with the following format:
<request-id> <remote-address> <name> <user-id> <time> <duration> "<method> <path> <protocol>" <status> <size>
If a field is not known, the hyphen symbol (-) will be used.
type Logger ¶
Logger is an alias of logrus.Logger.
func New ¶
func New(name string, raw json.RawMessage) (*Logger, error)
New initializes the logger with the given options.
func (*Logger) GetTraceHeader ¶
GetTraceHeader returns the trace header configured
type LoggerHandler ¶
type LoggerHandler struct {
// contains filtered or unexported fields
}
LoggerHandler creates a logger handler
func (*LoggerHandler) ServeHTTP ¶
func (l *LoggerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler and call to the handler to log with a custom http.ResponseWriter that records the response code and the number of bytes sent.
type ResponseLogger ¶
type ResponseLogger interface { http.ResponseWriter Size() int StatusCode() int Fields() map[string]interface{} WithFields(map[string]interface{}) }
ResponseLogger defines an interface that a responseWrite can implement to support the capture of the status code, the number of bytes written and extra log entry fields.
func NewResponseLogger ¶
func NewResponseLogger(w http.ResponseWriter) ResponseLogger
NewResponseLogger wraps the given response writer with methods to capture the status code, the number of bytes written, and methods to add new log entries. It won't wrap the response writer if it's already a ResponseLogger.