33 lines
769 B
Go
33 lines
769 B
Go
package toolkit
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"dev.mediocregopher.com/mediocre-go-lib.git/mlog"
|
|
)
|
|
|
|
type logLevel struct {
|
|
level int
|
|
name string
|
|
}
|
|
|
|
func (l logLevel) Int() int { return l.level }
|
|
func (l logLevel) String() string { return l.name }
|
|
|
|
var (
|
|
// LogLevelChild is used for logging out the stdout, stderr, and system logs
|
|
// (from pmux) related to child processes.
|
|
LogLevelChild mlog.Level = logLevel{mlog.LevelInfo.Int() + 1, "CHILD"}
|
|
)
|
|
|
|
// LogLevelFromString parses a string as a log level, taking into account custom
|
|
// log levels introduced in Isle.
|
|
func LogLevelFromString(str string) mlog.Level {
|
|
switch strings.TrimSpace(strings.ToUpper(str)) {
|
|
case LogLevelChild.String():
|
|
return LogLevelChild
|
|
default:
|
|
return mlog.LevelFromString(str)
|
|
}
|
|
}
|