netmaker/logger/util.go

31 lines
558 B
Go
Raw Normal View History

2022-02-11 00:07:21 +08:00
package logger
import (
"os"
"strconv"
"strings"
)
// MakeString - makes a string using golang string builder
func MakeString(delimeter string, message ...string) string {
var builder strings.Builder
2022-02-12 04:20:19 +08:00
for i := range message {
2022-02-11 00:07:21 +08:00
builder.WriteString(message[i])
if delimeter != "" && i != len(message)-1 {
builder.WriteString(delimeter)
}
}
return builder.String()
}
func getVerbose() int32 {
level, err := strconv.Atoi(os.Getenv("VERBOSITY"))
if err != nil || level < 0 {
level = 0
}
if level > 3 {
level = 3
}
return int32(level)
}