Skip to content

Commit 232751e

Browse files
committed
improve context key and caller path&func outputs for logger of package glog
1 parent 1c600d5 commit 232751e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

database/gdb/gdb_core.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,9 @@ func (c *Core) writeSqlToLogger(ctx context.Context, sql *Sql) {
658658
s := fmt.Sprintf("[%3d ms] [%s] %s%s", sql.End-sql.Start, sql.Group, transactionIdStr, sql.Format)
659659
if sql.Error != nil {
660660
s += "\nError: " + sql.Error.Error()
661-
c.logger.Error(ctx, s)
661+
c.logger.Ctx(ctx).Error(s)
662662
} else {
663-
c.logger.Debug(ctx, s)
663+
c.logger.Ctx(ctx).Debug(s)
664664
}
665665
}
666666

os/glog/glog_logger_handler.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ func (i *HandlerInput) getBuffer(withColor bool) *bytes.Buffer {
6161
i.addStringToBuffer(buffer, i.LevelFormat)
6262
}
6363
}
64-
if i.CallerFunc != "" {
65-
i.addStringToBuffer(buffer, i.CallerFunc)
66-
}
67-
if i.CallerPath != "" {
68-
i.addStringToBuffer(buffer, i.CallerPath)
69-
}
7064
if i.Prefix != "" {
7165
i.addStringToBuffer(buffer, i.Prefix)
7266
}
7367
if i.CtxStr != "" {
7468
i.addStringToBuffer(buffer, i.CtxStr)
7569
}
70+
if i.CallerFunc != "" {
71+
i.addStringToBuffer(buffer, i.CallerFunc)
72+
}
73+
if i.CallerPath != "" {
74+
i.addStringToBuffer(buffer, i.CallerPath)
75+
}
7676
if i.Content != "" {
7777
i.addStringToBuffer(buffer, i.Content)
7878
}

0 commit comments

Comments
 (0)