26 lines
383 B
Go
26 lines
383 B
Go
package klog
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"kumoly.io/lib/klog/color"
|
|
)
|
|
|
|
func (l *Logger) M(s interface{}, attrs ...color.Attribute) string {
|
|
if !l.color {
|
|
return fmt.Sprint(s)
|
|
}
|
|
styles := ""
|
|
for i, v := range attrs {
|
|
if i >= 3 {
|
|
break
|
|
}
|
|
if i > 0 {
|
|
styles += ";"
|
|
}
|
|
styles = styles + strconv.Itoa(int(v))
|
|
}
|
|
return fmt.Sprintf("\033[%sm%s\033[0m", styles, s)
|
|
}
|