mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
- Updated all `github.com/luispater/CLIProxyAPI/internal/...` imports to point to `github.com/luispater/CLIProxyAPI/v5/internal/...`. - Adjusted `go.mod` to specify `module github.com/luispater/CLIProxyAPI/v5`.
24 lines
613 B
Go
24 lines
613 B
Go
package util
|
|
|
|
import (
|
|
"github.com/luispater/CLIProxyAPI/v5/internal/config"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// SetLogLevel configures the logrus log level based on the configuration.
|
|
// It sets the log level to DebugLevel if debug mode is enabled, otherwise to InfoLevel.
|
|
func SetLogLevel(cfg *config.Config) {
|
|
currentLevel := log.GetLevel()
|
|
var newLevel log.Level
|
|
if cfg.Debug {
|
|
newLevel = log.DebugLevel
|
|
} else {
|
|
newLevel = log.InfoLevel
|
|
}
|
|
|
|
if currentLevel != newLevel {
|
|
log.SetLevel(newLevel)
|
|
log.Infof("log level changed from %s to %s (debug=%t)", currentLevel, newLevel, cfg.Debug)
|
|
}
|
|
}
|