mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-24 13:05:17 +00:00
18 lines
364 B
Go
18 lines
364 B
Go
|
package logrusutil
|
||
|
|
||
|
import "github.com/sirupsen/logrus"
|
||
|
|
||
|
// StackLogLevel temporary change log level and return recover function
|
||
|
func StackLogLevel(logger *logrus.Logger, level logrus.Level) (recover func()) {
|
||
|
if logger.Level == level {
|
||
|
return func() {}
|
||
|
}
|
||
|
|
||
|
originLevel := logger.Level
|
||
|
logger.Level = level
|
||
|
|
||
|
return func() {
|
||
|
logger.Level = originLevel
|
||
|
}
|
||
|
}
|