aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2025-03-08 21:47:11 +0800
committerGitHub <noreply@github.com>2025-03-08 21:47:11 +0800
commit4ed71eb7543b471030af77f362326bd745a39fb4 (patch)
tree794a27a65604922bcbc4ed2df00b639ddc2d0810 /services
parent6422f05a4e2610a31b6137267b7bf53ae1b2b093 (diff)
downloadgitea-4ed71eb7543b471030af77f362326bd745a39fb4.tar.gz
gitea-4ed71eb7543b471030af77f362326bd745a39fb4.zip
Improve log format (#33814)
Diffstat (limited to 'services')
-rw-r--r--services/context/access_log.go2
-rw-r--r--services/context/access_log_test.go2
-rw-r--r--services/doctor/doctor.go8
3 files changed, 6 insertions, 6 deletions
diff --git a/services/context/access_log.go b/services/context/access_log.go
index 001d93a362..925e4a3056 100644
--- a/services/context/access_log.go
+++ b/services/context/access_log.go
@@ -92,7 +92,7 @@ func (lr *accessLogRecorder) record(start time.Time, respWriter ResponseWriter,
log.Error("Could not execute access logger template: %v", err.Error())
}
- lr.logger.Log(1, log.INFO, "%s", buf.String())
+ lr.logger.Log(1, &log.Event{Level: log.INFO}, "%s", buf.String())
}
func newAccessLogRecorder() *accessLogRecorder {
diff --git a/services/context/access_log_test.go b/services/context/access_log_test.go
index bd3e47e0cc..c40ef9acd1 100644
--- a/services/context/access_log_test.go
+++ b/services/context/access_log_test.go
@@ -20,7 +20,7 @@ type testAccessLoggerMock struct {
logs []string
}
-func (t *testAccessLoggerMock) Log(skip int, level log.Level, format string, v ...any) {
+func (t *testAccessLoggerMock) Log(skip int, event *log.Event, format string, v ...any) {
t.logs = append(t.logs, fmt.Sprintf(format, v...))
}
diff --git a/services/doctor/doctor.go b/services/doctor/doctor.go
index a4eb5e16b9..c6810a5fa0 100644
--- a/services/doctor/doctor.go
+++ b/services/doctor/doctor.go
@@ -48,7 +48,7 @@ type doctorCheckLogger struct {
var _ log.BaseLogger = (*doctorCheckLogger)(nil)
-func (d *doctorCheckLogger) Log(skip int, level log.Level, format string, v ...any) {
+func (d *doctorCheckLogger) Log(skip int, event *log.Event, format string, v ...any) {
_, _ = fmt.Fprintf(os.Stdout, format+"\n", v...)
}
@@ -62,11 +62,11 @@ type doctorCheckStepLogger struct {
var _ log.BaseLogger = (*doctorCheckStepLogger)(nil)
-func (d *doctorCheckStepLogger) Log(skip int, level log.Level, format string, v ...any) {
- levelChar := fmt.Sprintf("[%s]", strings.ToUpper(level.String()[0:1]))
+func (d *doctorCheckStepLogger) Log(skip int, event *log.Event, format string, v ...any) {
+ levelChar := fmt.Sprintf("[%s]", strings.ToUpper(event.Level.String()[0:1]))
var levelArg any = levelChar
if d.colorize {
- levelArg = log.NewColoredValue(levelChar, level.ColorAttributes()...)
+ levelArg = log.NewColoredValue(levelChar, event.Level.ColorAttributes()...)
}
args := append([]any{levelArg}, v...)
_, _ = fmt.Fprintf(os.Stdout, " - %s "+format+"\n", args...)