rest log with context (#998)

This commit is contained in:
Kevin Wan
2021-09-05 22:58:42 +08:00
committed by GitHub
parent 79eab0ea2f
commit 6476da4a18

View File

@@ -54,12 +54,12 @@ func (lc *LogCollector) takeAll() []string {
// Error logs the given v along with r in error log. // Error logs the given v along with r in error log.
func Error(r *http.Request, v ...interface{}) { func Error(r *http.Request, v ...interface{}) {
logx.WithContext(r.Context()).Error(v) logx.WithContext(r.Context()).Error(format(r, v...))
} }
// Errorf logs the given v with format along with r in error log. // Errorf logs the given v with format along with r in error log.
func Errorf(r *http.Request, format string, v ...interface{}) { func Errorf(r *http.Request, format string, v ...interface{}) {
logx.WithContext(r.Context()).Errorf(format, v) logx.WithContext(r.Context()).Error(formatf(r, format, v...))
} }
// Info logs the given v along with r in access log. // Info logs the given v along with r in access log.