github.com/sagernet/sing-box@v1.9.0-rc.20/log/override.go (about) 1 package log 2 3 import ( 4 "context" 5 ) 6 7 type overrideLevelKey struct{} 8 9 func ContextWithOverrideLevel(ctx context.Context, level Level) context.Context { 10 return context.WithValue(ctx, (*overrideLevelKey)(nil), level) 11 } 12 13 func OverrideLevelFromContext(origin Level, ctx context.Context) Level { 14 level, loaded := ctx.Value((*overrideLevelKey)(nil)).(Level) 15 if !loaded || origin > level { 16 return origin 17 } 18 return level 19 }