package nlog import ( "git.noahlan.cn/noahlan/ntool/nstr" "github.com/gookit/color" "sync/atomic" ) // WithColor is a helper function to add color to a string, only in plain encoding. func WithColor(text string, colour color.Color) string { if atomic.LoadUint32(&encoding) == plainEncodingType { return colour.Render(text) } return text } // WithColorPadding is a helper function to add color to a string with leading and trailing spaces, // only in plain encoding. func WithColorPadding(text string, colour color.Color) string { return WithColor(nstr.PadAround(text, " ", len(text)+2), colour) }