@@ -207,7 +207,7 @@ func (ph *PoolHook) onDemandWorker() {
207207 return
208208 case <- time .After (ph .workerTimeout ):
209209 // Worker has been idle for too long, exit to save resources
210- if ph .config != nil && ph .config .LogLevel >= LogLevelDebug { // Debug level
210+ if ph .config != nil && ph .config .LogLevel . InfoOrAbove () { // Debug level
211211 internal .Logger .Printf (context .Background (),
212212 "hitless: worker exiting due to inactivity timeout (%v)" , ph .workerTimeout )
213213 }
@@ -302,14 +302,14 @@ func (ph *PoolHook) closeConnFromRequest(ctx context.Context, request HandoffReq
302302 conn := request .Conn
303303 if pooler != nil {
304304 pooler .Remove (ctx , conn , err )
305- if ph .config != nil && ph .config .LogLevel >= LogLevelWarn { // Warning level
305+ if ph .config != nil && ph .config .LogLevel . WarnOrAbove () { // Warning level
306306 internal .Logger .Printf (ctx ,
307307 "hitless: removed conn[%d] from pool due to max handoff retries reached: %v" ,
308308 conn .GetID (), err )
309309 }
310310 } else {
311311 conn .Close ()
312- if ph .config != nil && ph .config .LogLevel >= LogLevelWarn { // Warning level
312+ if ph .config != nil && ph .config .LogLevel . WarnOrAbove () { // Warning level
313313 internal .Logger .Printf (ctx ,
314314 "hitless: no pool provided for conn[%d], cannot remove due to handoff initialization failure: %v" ,
315315 conn .GetID (), err )
@@ -357,11 +357,11 @@ func (ph *PoolHook) queueHandoff(conn *pool.Conn) error {
357357 // Queue is full - log and attempt scaling
358358 queueLen := len (ph .handoffQueue )
359359 queueCap := cap (ph .handoffQueue )
360- if ph .config != nil && ph .config .LogLevel >= LogLevelWarn { // Warning level
360+ if ph .config != nil && ph .config .LogLevel . WarnOrAbove () { // Warning level
361361 internal .Logger .Printf (context .Background (),
362362 "hitless: handoff queue is full (%d/%d), cant queue handoff request for conn[%d] seqID[%d]" ,
363363 queueLen , queueCap , request .ConnID , request .SeqID )
364- if ph .config .LogLevel >= LogLevelDebug { // Debug level
364+ if ph .config .LogLevel . DebugOrAbove () { // Debug level
365365 ph .pending .Range (func (k , v interface {}) bool {
366366 internal .Logger .Printf (context .Background (), "hitless: pending handoff for conn[%d] seqID[%d]" , k , v )
367367 return true
@@ -396,7 +396,7 @@ func (ph *PoolHook) performConnectionHandoff(ctx context.Context, conn *pool.Con
396396 }
397397
398398 if retries > maxRetries {
399- if ph .config != nil && ph .config .LogLevel >= LogLevelWarn { // Warning level
399+ if ph .config != nil && ph .config .LogLevel . WarnOrAbove () { // Warning level
400400 internal .Logger .Printf (ctx ,
401401 "hitless: reached max retries (%d) for handoff of conn[%d] to %s" ,
402402 maxRetries , conn .GetID (), conn .GetHandoffEndpoint ())
@@ -430,7 +430,7 @@ func (ph *PoolHook) performConnectionHandoff(ctx context.Context, conn *pool.Con
430430 deadline := time .Now ().Add (ph .config .PostHandoffRelaxedDuration )
431431 conn .SetRelaxedTimeoutWithDeadline (relaxedTimeout , relaxedTimeout , deadline )
432432
433- if ph .config .LogLevel >= 2 { // Info level
433+ if ph .config .LogLevel . InfoOrAbove () {
434434 internal .Logger .Printf (context .Background (),
435435 "hitless: conn[%d] applied post-handoff relaxed timeout (%v) until %v" ,
436436 connID , relaxedTimeout , deadline .Format ("15:04:05.000" ))
0 commit comments