mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-05-23 00:15:19 +03:00
Add log levels (#332)
This commit is contained in:
parent
d1cf0ca7eb
commit
3d59c7d0de
5 changed files with 56 additions and 17 deletions
|
@ -42,6 +42,7 @@ const (
|
|||
PersistentKeepaliveEnvVar = "WGUI_PERSISTENT_KEEPALIVE"
|
||||
ForwardMarkEnvVar = "WGUI_FORWARD_MARK"
|
||||
ConfigFilePathEnvVar = "WGUI_CONFIG_FILE_PATH"
|
||||
LogLevel = "WGUI_LOG_LEVEL"
|
||||
ServerAddressesEnvVar = "WGUI_SERVER_INTERFACE_ADDRESSES"
|
||||
ServerListenPortEnvVar = "WGUI_SERVER_LISTEN_PORT"
|
||||
ServerPostUpScriptEnvVar = "WGUI_SERVER_POST_UP_SCRIPT"
|
||||
|
|
16
util/util.go
16
util/util.go
|
@ -469,6 +469,22 @@ func LookupEnvOrStrings(key string, defaultVal []string) []string {
|
|||
return defaultVal
|
||||
}
|
||||
|
||||
func ParseLogLevel(lvl string) (log.Lvl, error) {
|
||||
switch strings.ToLower(lvl) {
|
||||
case "debug":
|
||||
return log.DEBUG, nil
|
||||
case "info":
|
||||
return log.INFO, nil
|
||||
case "warn":
|
||||
return log.WARN, nil
|
||||
case "error":
|
||||
return log.ERROR, nil
|
||||
case "off":
|
||||
return log.OFF, nil
|
||||
default:
|
||||
return log.DEBUG, fmt.Errorf("not a valid log level: %s", lvl)
|
||||
}
|
||||
|
||||
// GetCurrentHash returns current hashes
|
||||
func GetCurrentHash(db store.IStore) (string, string) {
|
||||
hashClients, _ := dirhash.HashDir(path.Join(db.GetPath(), "clients"), "prefix", dirhash.Hash1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue