github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/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() }