Documentation ¶
Index ¶
Constants ¶
View Source
const ( Black = "\u001b[30m" Red = "\u001b[31m" Green = "\u001b[32m" Yellow = "\u001b[33m" Blue = "\u001b[34m" Magenta = "\u001b[35m" Cyan = "\u001b[36m" White = "\u001b[37m" BrightWhite = "\u001b[37;1m" Gray = "\u001b[38;5;102m" Reset = "\u001b[0m" )
View Source
const ( // LevelError is the error logging level. LevelError = 0 // LevelWarn is the warning logging level. LevelWarn = 1 // LevelInfo is the info logging level. LevelInfo = 2 // LevelDebug is the debug logging level. LevelDebug = 3 )
Variables ¶
This section is empty.
Functions ¶
func CheckIfError ¶
func CheckIfError(err error)
CheckIfError uses DefaultPrinter to print the given error and exit the program.
func DebugF ¶
func DebugF(format string, args ...interface{})
DebugF uses DefaultPrinter to log the given format string and its arguments.
Types ¶
type Color ¶
type Color string
var ( // DebugColor is the color which is used for LevelDebug logging level. DebugColor Color = Gray // InfoColor is the color which is used for LevelInfo logging level. InfoColor Color = BrightWhite // WarnColor is the color which is used for LevelWarn logging level. WarnColor Color = Yellow // ErrorColor is the color which is used for LevelError logging level. ErrorColor Color = Red )
type LogLevel ¶
type LogLevel int
func ParseLogLevel ¶
ParseLogLevel returns the parsed log level from a given lower-cased string. If it cannot be parsed, the LevelInfo is returned along with an error.
type PipelineLogger ¶
type PipelineLogger struct {
Logger Printer
}
PipelineLogger is the implementation for the pipeline lib.
func (PipelineLogger) Log ¶
func (p PipelineLogger) Log(message, name string)
Log prints the message and name to debug level.
type Printer ¶
type Printer interface { // DebugF sets the color to DebugColor, prints the string as given and resets the color, provided the LogLevel is LevelDebug or higher. DebugF(format string, args ...interface{}) // InfoF sets the color to InfoColor, prints the string as given and resets the color, provided the LogLevel is LevelInfo or higher. InfoF(format string, args ...interface{}) // WarnF sets the color to WarnColor, prints the string as given and resets the color, provided the LogLevel is LevelWarn or higher. WarnF(format string, args ...interface{}) // ErrorF sets the color to ErrorColor, prints the string as given and resets the color. ErrorF(format string, args ...interface{}) // PrintF formats the given format string and prints it to stdout without alterations. PrintF(format string, args ...interface{}) // LogF formats the given format string and prints it to stdout using the color set by UseColor, defaulting to InfoColor if not set. LogF(format string, args ...interface{}) // UseColor will internally save the given color and use it when LogF is invoked. UseColor(color Color) Printer // MapColorToLevel sets the color for the given log level. MapColorToLevel(color Color, level LogLevel) Printer // SetColor sets the given color without printing newline char and returns itself. // Best used with PrintF as other methods may reset the color before returning. SetColor(color Color) // ResetColor will reset the color to default. // Best used in a defer statement right after setting a color to not forget about resetting. ResetColor() // SetLevel sets the logging level. SetLevel(level LogLevel) Printer // SetName sets a prefix for DebugF, InfoF, WarnF SetName(name string) Printer // CheckIfError will print the error in ErrorColor to stderr if it is non-nil and exit with exit code 1. CheckIfError(err error) }
Printer represents a logging interface.
Click to show internal directories.
Click to hide internal directories.