small nit

This commit is contained in:
Lunny Xiao 2020-03-26 14:04:55 +08:00
parent edcf1e97fa
commit bbefd81704
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 3 additions and 2 deletions

View File

@ -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)

View File

@ -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 {