Add log levels ()

This commit is contained in:
ByteDream 2023-03-15 21:29:08 +01:00 committed by GitHub
parent d1cf0ca7eb
commit 3d59c7d0de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 17 deletions

View file

@ -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)