Documentation ¶
Index ¶
- Constants
- Variables
- func LogAll(_ *http.Request) (bool, bool, bool)
- func LogRecoverError(ctx context.Context, stackSkip int, recoverErr any)
- func LogRequestBody(_ *http.Request) (bool, bool, bool)
- func RecoverLogger(log zerolog.Logger) func(http.Handler) http.Handler
- func RequestLogger(shouldLog FnShouldLog) func(http.Handler) http.Handler
- func SimplifyStack(stack string, skip int) []string
- type FnShouldLog
Constants ¶
const ( Duration = "duration" // In nanoseconds HTTPStatusCode = "http.status_code" HTTPMethod = "http.method" HTTPURLDetailsPath = "http.url_details.path" NetworkBytesRead = "network.bytes_read" NetworkBytesWritten = "network.bytes_written" Operation = "op" Request = "request" RequestID = "http.request_id" RequestHeaders = "request.headers" RequestError = "request.body_error" Response = "response" TraceID = "trace_id" UserID = "usr.id" )
Reference: https://docs.datadoghq.com/logs/log_configuration/attributes_naming_convention/#http-requests
Variables ¶
var ErrInternal = errors.New("internal error")
ErrInternal is the default error returned from a panic.
var MaxBodyLog uint32 = 24 * 1024
MaxBodyLog controls the maximum request/response body that can be logged. Anything greater will be truncated.
var RecoverBasePath = initBasePath()
Functions ¶
func LogRecoverError ¶ added in v0.4.9
func RecoverLogger ¶ added in v0.3.3
RecoverLogger returns a handler that call initializes Op in the context, and logs each request.
func RequestLogger ¶
func RequestLogger(shouldLog FnShouldLog) func(http.Handler) http.Handler
RequestLogger returns a handler that call initializes Op in the context, and logs each request.
func SimplifyStack ¶ added in v0.4.9
Types ¶
type FnShouldLog ¶
FnShouldLog given a request, return flags that control logging. logRequest will disable the entire request logging middleware, default is true. logRequestBody will log the body of the request, default is false. logResponseBody will log the body of the response, default is false. This should be disabled for large or streaming results.