mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-27 11:31:06 +01:00
preparing for v0.5
This commit is contained in:
24
src/common/env.go
Normal file
24
src/common/env.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var IsRunningAsService = getEnvBool("GOPROXY_IS_SYSTEMD")
|
||||
var NoSchemaValidation = getEnvBool("GOPROXY_NO_SCHEMA_VALIDATION")
|
||||
var IsDebug = getEnvBool("GOPROXY_DEBUG")
|
||||
|
||||
var LogLevel = func() logrus.Level {
|
||||
if IsDebug {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
}
|
||||
return logrus.GetLevel()
|
||||
}()
|
||||
|
||||
func getEnvBool(key string) bool {
|
||||
v := os.Getenv(key)
|
||||
return v == "1" || strings.ToLower(v) == "true" || strings.ToLower(v) == "yes" || strings.ToLower(v) == "on"
|
||||
}
|
||||
Reference in New Issue
Block a user