summaryrefslogtreecommitdiffstats
path: root/modules/log/colors.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/log/colors.go')
-rw-r--r--modules/log/colors.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/log/colors.go b/modules/log/colors.go
index 02781afe84..85e205cb67 100644
--- a/modules/log/colors.go
+++ b/modules/log/colors.go
@@ -383,6 +383,13 @@ func (cv *ColoredValue) Format(s fmt.State, c rune) {
s.Write(*cv.resetBytes)
}
+// ColorFormatAsString returns the result of the ColorFormat without the color
+func ColorFormatAsString(colorVal ColorFormatted) string {
+ s := new(strings.Builder)
+ _, _ = ColorFprintf(&protectedANSIWriter{w: s, mode: removeColor}, "%-v", colorVal)
+ return s.String()
+}
+
// SetColorBytes will allow a user to set the colorBytes of a colored value
func (cv *ColoredValue) SetColorBytes(colorBytes []byte) {
cv.colorBytes = &colorBytes