storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/pkg/console/themes.go (about) 1 /* 2 * MinIO Cloud Storage, (C) 2019 MinIO, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package console 18 19 import "github.com/fatih/color" 20 21 var ( 22 // Theme contains default color mapping. 23 Theme = map[string]*color.Color{ 24 "Debug": color.New(color.FgWhite, color.Faint, color.Italic), 25 "Fatal": color.New(color.FgRed, color.Italic, color.Bold), 26 "Error": color.New(color.FgYellow, color.Italic), 27 "Info": color.New(color.FgGreen, color.Bold), 28 "Print": color.New(), 29 "PrintB": color.New(color.FgBlue, color.Bold), 30 "PrintC": color.New(color.FgGreen, color.Bold), 31 } 32 ) 33 34 // SetColorOff disables coloring for the entire session. 35 func SetColorOff() { 36 privateMutex.Lock() 37 defer privateMutex.Unlock() 38 color.NoColor = true 39 } 40 41 // SetColorOn enables coloring for the entire session. 42 func SetColorOn() { 43 privateMutex.Lock() 44 defer privateMutex.Unlock() 45 color.NoColor = false 46 } 47 48 // SetColor sets a color for a particular tag. 49 func SetColor(tag string, cl *color.Color) { 50 privateMutex.Lock() 51 defer privateMutex.Unlock() 52 // add new theme 53 Theme[tag] = cl 54 }