Documentation ¶
Index ¶
- Constants
- Variables
- func Black(format string, a ...any)
- func BlackString(format string, a ...any) string
- func Blue(format string, a ...any)
- func BlueString(format string, a ...any) string
- func ConsolePrinter(log LogInstance, packageName string, fileName string, lineNumber int, ...)
- func Cyan(format string, a ...any)
- func CyanString(format string, a ...any) string
- func Debug(format string, v ...any)
- func Error(format string, v ...any)
- func FilePrinter(log LogInstance, packageName string, fileName string, lineNumber int, ...)
- func Green(format string, a ...any)
- func GreenString(format string, a ...any) string
- func Info(format string, v ...any)
- func Magenta(format string, a ...any)
- func MagentaString(format string, a ...any) string
- func OutPrint(format string, v []any) string
- func Print(log LogInstance, packageName string, fileName string, lineNumber int, ...)
- func Red(format string, a ...any)
- func RedString(format string, a ...any) string
- func Unset()
- func Warn(format string, v ...any)
- func White(format string, a ...any)
- func WhiteString(format string, a ...any) string
- func Yellow(format string, a ...any)
- func YellowString(format string, a ...any) string
- type Attribute
- type Color
- func (c *Color) Add(value ...Attribute) *Color
- func (c *Color) DisableColor()
- func (c *Color) EnableColor()
- func (c *Color) Equals(c2 *Color) bool
- func (c *Color) Print(a ...any) (n int, err error)
- func (c *Color) PrintFunc() func(a ...any)
- func (c *Color) Printf(format string, a ...any) (n int, err error)
- func (c *Color) PrintfFunc() func(format string, a ...any)
- func (c *Color) Println(a ...any) (n int, err error)
- func (c *Color) PrintlnFunc() func(a ...any)
- func (c *Color) Set() *Color
- func (c *Color) SprintFunc() func(a ...any) string
- func (c *Color) SprintfFunc() func(format string, a ...any) string
- func (c *Color) SprintlnFunc() func(a ...any) string
- type GoLogger
- func (log GoLogger) Debug(message string)
- func (log GoLogger) Error(message string)
- func (log GoLogger) Fatal(message string)
- func (log GoLogger) Info(message string)
- func (log GoLogger) Log(message string)
- func (log GoLogger) Message(message string)
- func (log GoLogger) ReplaceMessage(message string)
- func (log GoLogger) Warn(message string)
- type LogInstance
- type Logger
Constants ¶
Variables ¶
var NoColor = !isatty.IsTerminal(os.Stdout.Fd())
NoColor defines if the output is colorized or not. It's dynamically set to false or true based on the stdout's file descriptor referring to a terminal or not. This is a global option and affects all colors. For more control over each color block use the methods DisableColor() individually.
var Output = ansicolor.NewAnsiColorWriter(os.Stdout)
Output defines the standard output of the print functions. By default os.Stdout is used.
Functions ¶
func Black ¶
Black is an convenient helper function to print with black foreground. A newline is appended to format by default.
func BlackString ¶
BlackString is an convenient helper function to return a string with black foreground.
func Blue ¶
Blue is an convenient helper function to print with blue foreground. A newline is appended to format by default.
func BlueString ¶
BlueString is an convenient helper function to return a string with blue foreground.
func ConsolePrinter ¶
func Cyan ¶
Cyan is an convenient helper function to print with cyan foreground. A newline is appended to format by default.
func CyanString ¶
CyanString is an convenient helper function to return a string with cyan foreground.
func FilePrinter ¶
func Green ¶
Green is an convenient helper function to print with green foreground. A newline is appended to format by default.
func GreenString ¶
GreenString is an convenient helper function to return a string with green foreground.
func Magenta ¶
Magenta is an convenient helper function to print with magenta foreground. A newline is appended to format by default.
func MagentaString ¶
MagentaString is an convenient helper function to return a string with magenta foreground.
func Red ¶
Red is an convenient helper function to print with red foreground. A newline is appended to format by default.
func Unset ¶
func Unset()
Unset resets all escape attributes and clears the output. Usually should be called after Set().
func White ¶
White is an convenient helper function to print with white foreground. A newline is appended to format by default.
func WhiteString ¶
WhiteString is an convenient helper function to return a string with white foreground.
func Yellow ¶
Yellow is an convenient helper function to print with yellow foreground. A newline is appended to format by default.
func YellowString ¶
YellowString is an convenient helper function to return a string with yellow foreground.
Types ¶
type Attribute ¶
type Attribute int
Attribute defines a single SGR Code
const ( Reset Attribute = iota Bold Faint Italic Underline BlinkSlow BlinkRapid ReverseVideo Concealed CrossedOut )
Base attributes
Foreground text colors
type Color ¶
type Color struct {
// contains filtered or unexported fields
}
Color defines a custom color object which is defined by SGR parameters.
func Set ¶
Set sets the given parameters immediately. It will change the color of output with the given SGR parameters until color.Unset() is called.
func (*Color) Add ¶
Add is used to chain SGR parameters. Use as many as parameters to combine and create custom color objects. Example: Add(color.FgRed, color.Underline).
func (*Color) DisableColor ¶
func (c *Color) DisableColor()
DisableColor disables the color output. Useful to not change any existing code and still being able to output. Can be used for flags like "--no-color". To enable back use EnableColor() method.
func (*Color) EnableColor ¶
func (c *Color) EnableColor()
EnableColor enables the color output. Use it in conjuction with DisableColor(). Otherwise this method has no side effects.
func (*Color) Print ¶
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered. This is the standard fmt.Print() method wrapped with the given color.
func (*Color) PrintFunc ¶
PrintFunc returns a new function that prints the passed arguments as colorized with color.Print().
func (*Color) Printf ¶
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered. This is the standard fmt.Printf() method wrapped with the given color.
func (*Color) PrintfFunc ¶
PrintfFunc returns a new function that prints the passed arguments as colorized with color.Printf().
func (*Color) Println ¶
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. This is the standard fmt.Print() method wrapped with the given color.
func (*Color) PrintlnFunc ¶
PrintlnFunc returns a new function that prints the passed arguments as colorized with color.Println().
func (*Color) SprintFunc ¶
SprintFunc returns a new function that returns colorized strings for the given arguments with fmt.Sprint(). Useful to put into or mix into other string. Windows users should use this in conjuction with color.Output, example:
put := New(FgYellow).SprintFunc() fmt.Fprintf(color.Output, "This is a %s", put("warning"))
func (*Color) SprintfFunc ¶
SprintfFunc returns a new function that returns colorized strings for the given arguments with fmt.Sprintf(). Useful to put into or mix into other string. Windows users should use this in conjuction with color.Output.
func (*Color) SprintlnFunc ¶
SprintlnFunc returns a new function that returns colorized strings for the given arguments with fmt.Sprintln(). Useful to put into or mix into other string. Windows users should use this in conjuction with color.Output.