github.com/sykesm/fabric@v1.1.0-preview.0.20200129034918-2aa12b1a0181/common/flogging/fabenc/color.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package fabenc 8 9 import ( 10 "fmt" 11 ) 12 13 type Color uint8 14 15 const ColorNone Color = 0 16 17 const ( 18 ColorBlack Color = iota + 30 19 ColorRed 20 ColorGreen 21 ColorYellow 22 ColorBlue 23 ColorMagenta 24 ColorCyan 25 ColorWhite 26 ) 27 28 func (c Color) Normal() string { 29 return fmt.Sprintf("\x1b[%dm", c) 30 } 31 32 func (c Color) Bold() string { 33 if c == ColorNone { 34 return c.Normal() 35 } 36 return fmt.Sprintf("\x1b[%d;1m", c) 37 } 38 39 func ResetColor() string { return ColorNone.Normal() }