go-hep.org/x/hep@v0.38.1/fwk/job/utils.go (about) 1 // Copyright ©2017 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package job 6 7 import ( 8 "fmt" 9 "strings" 10 11 "go-hep.org/x/hep/fwk" 12 ) 13 14 // MsgLevel returns the fwk.Level according to the given lvl string value. 15 // MsgLevel panics if no fwk.Level value corresponds to the lvl string value. 16 // Valid values are: "DEBUG", "INFO", "WARNING"|"WARN" and "ERROR"|"ERR". 17 func MsgLevel(lvl string) fwk.Level { 18 switch strings.ToUpper(lvl) { 19 case "DEBUG": 20 return fwk.LvlDebug 21 case "INFO": 22 return fwk.LvlInfo 23 case "WARNING", "WARN": 24 return fwk.LvlWarning 25 case "ERROR", "ERR": 26 return fwk.LvlError 27 default: 28 panic(fmt.Errorf("fwk.MsgLevel: invalid fwk.Level string %q", lvl)) 29 } 30 }