// ErrorLogEncoder decorates the errorEncoder in such a way that
// errors are logged with their corresponding unique request identifier
ErrorLogEncoder decorates the errorEncoder in such a way that
errors are logged with their corresponding unique request identifier
// ErrorLogEncoder decorates the errorEncoder in such a way that // errors are logged with their corresponding unique request identifier
func ErrorLogEncoder(getLogger GetLoggerFunc, ee kithttp.ErrorEncoder) kithttp.ErrorEncoder {
	if getLogger == nil {
		getLogger = func(_ context.Context) kitlog.Logger {
			return nil
		}
	}
	return func(ctx context.Context, e error, w http.ResponseWriter) {
		code := http.StatusInternalServerError
		var sc kithttp.StatusCoder
		if errors.As(e, &sc) {
			code = sc.StatusCode()
		}
		logger := getLogger(ctx)
		if logger != nil && code != http.StatusNotFound {
			logger.Log("sending non-200 response, non-404 response", level.Key(), level.ErrorValue(),
				logging.ErrorKey(), e.Error(), "tid", ctx.Value(ContextKeyRequestTID).(string),
			)
		}
		ee(ctx, e, w)
	}
}
func ErrorLogEncoder ( getLogger GetLoggerFunc , ee kithttp . ErrorEncoder ) kithttp . ErrorEncoder { if getLogger == nil { getLogger = func ( _ context . Context ) kitlog . Logger { return nil } } return func ( ctx context . Context , e error , w http . ResponseWriter ) { code := http . StatusInternalServerError var sc kithttp . StatusCoder if errors . As ( e , & sc ) { code = sc . StatusCode ( ) } logger := getLogger ( ctx ) if logger != nil && code != http . StatusNotFound { logger . Log ( " " , level . Key ( ) , level . ErrorValue ( ) , logging . ErrorKey ( ) , e . Error ( ) , " " , ctx . Value ( ContextKeyRequestTID ) . ( string ) , ) } ee ( ctx , e , w ) } }
ErrorLogEncoder decorates the errorEncoder in such a way that
errors are logged with their corresponding unique request identifier
ErrorLogEncoder decorates the errorEncoder in such a way that errors are logged with their corresponding unique request identifier