From bbefd81704ad77170c860fc34eb8321449d9e0dc Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 26 Mar 2020 14:04:55 +0800 Subject: [PATCH] small nit --- log/logger_context.go | 4 ++-- xorm.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/log/logger_context.go b/log/logger_context.go index 06946f47..c2d94dc6 100644 --- a/log/logger_context.go +++ b/log/logger_context.go @@ -70,8 +70,8 @@ func (l *LoggerAdapter) BeforeSQL(ctx LogContext) {} func (l *LoggerAdapter) AfterSQL(ctx LogContext) { var sessionPart string v := ctx.Ctx.Value(SessionIDKey) - if v != nil { - sessionPart = fmt.Sprintf(" [%s]", v.(string)) + if key, ok := v.(string); ok { + sessionPart = fmt.Sprintf(" [%s]", key) } if ctx.ExecuteTime > 0 { l.logger.Infof("[SQL]%s %s %v - %v", sessionPart, ctx.SQL, ctx.Args, ctx.ExecuteTime) diff --git a/xorm.go b/xorm.go index e9cd7415..2fe32e50 100644 --- a/xorm.go +++ b/xorm.go @@ -51,6 +51,7 @@ func NewEngine(driverName string, dataSourceName string) (*Engine, error) { driverName: driverName, dataSourceName: dataSourceName, db: db, + logSessionID: false, } if dialect.URI().DBType == schemas.SQLITE {