Skip to content

Commit 3084a65

Browse files
committed
Exposed StrToLevel and LevelToStr
1 parent 10ed378 commit 3084a65

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

level.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const (
3737
type Level int
3838

3939
func (l Level) String() string {
40-
return levelToStr(l)
40+
return LevelToStr(l)
4141
}
4242

4343
// StringColor terminal colored string
@@ -62,18 +62,19 @@ func (l Level) StringColor() string {
6262

6363
// MarshalJSON json serializer
6464
func (l *Level) MarshalJSON() ([]byte, error) {
65-
return json.Marshal(levelToStr(*l))
65+
return json.Marshal(LevelToStr(*l))
6666
}
6767

6868
// UnmarshalJSON json unserializer
6969
func (l *Level) UnmarshalJSON(b []byte) error {
7070
var str string
7171
err := json.Unmarshal(b, &str)
72-
*l = strToLevel(str)
72+
*l = StrToLevel(str)
7373
return err
7474
}
7575

76-
func strToLevel(str string) Level {
76+
// StrToLevel converts a string to a Level type
77+
func StrToLevel(str string) Level {
7778
str = strings.ToUpper(str)
7879
var level Level
7980
switch str {
@@ -91,7 +92,8 @@ func strToLevel(str string) Level {
9192
return level
9293
}
9394

94-
func levelToStr(level Level) string {
95+
// LevelToStr Level type to a string
96+
func LevelToStr(level Level) string {
9597
var str string
9698

9799
switch level {

0 commit comments

Comments
 (0)