Used to monitor which DB executed this SQL
This commit is contained in:
parent
1a39682180
commit
da55c35b25
10
session.go
10
session.go
|
@ -101,13 +101,15 @@ func newSessionID() string {
|
||||||
|
|
||||||
func newSession(engine *Engine) *Session {
|
func newSession(engine *Engine) *Session {
|
||||||
var ctx context.Context
|
var ctx context.Context
|
||||||
|
var sessionID string
|
||||||
if engine.logSessionID {
|
if engine.logSessionID {
|
||||||
ctx = context.WithValue(engine.defaultContext, log.SessionIDKey, newSessionID())
|
sessionID = newSessionID()
|
||||||
|
ctx = context.WithValue(engine.defaultContext, log.SessionIDKey, sessionID)
|
||||||
} else {
|
} else {
|
||||||
ctx = engine.defaultContext
|
ctx = engine.defaultContext
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Session{
|
session := &Session{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
engine: engine,
|
engine: engine,
|
||||||
tx: nil,
|
tx: nil,
|
||||||
|
@ -136,6 +138,10 @@ func newSession(engine *Engine) *Session {
|
||||||
|
|
||||||
sessionType: engineSession,
|
sessionType: engineSession,
|
||||||
}
|
}
|
||||||
|
if engine.logSessionID {
|
||||||
|
ctx = context.WithValue(engine.defaultContext, sessionID, session)
|
||||||
|
}
|
||||||
|
return session
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close release the connection from pool
|
// Close release the connection from pool
|
||||||
|
|
Loading…
Reference in New Issue