Documentation
¶
Overview ¶
Package logger is a simplified logger which only handles two basic log levels.
Index ¶
- Variables
- func WithColors(enabled bool) func(*Logger)
- func WithDebug(enabled bool) func(*Logger)
- func WithErrorOutput(w io.Writer) func(*Logger)
- type Logger
- func (l Logger) Debug(a ...interface{})
- func (l Logger) Debugf(format string, a ...interface{})
- func (l Logger) Debugln(a ...interface{})
- func (l Logger) Error(a ...interface{})
- func (l Logger) Errorf(format string, a ...interface{})
- func (l Logger) Errorln(a ...interface{})
- func (l Logger) Info(a ...interface{})
- func (l Logger) Infof(format string, a ...interface{})
- func (l Logger) Infoln(a ...interface{})
Constants ¶
This section is empty.
Variables ¶
var ( // Success colors a message in bold green to represent success. Success = color.New(color.FgGreen, color.Bold).SprintFunc() // Failure colors a message in bold red to represent failure. Failure = color.New(color.FgRed, color.Bold).SprintFunc() // Trace colors a message in faint white (usually rendered in gray) // to represent a log of low importance for the user. Trace = color.New(color.FgHiWhite, color.Faint).SprintFunc() // Important colors a message in bold to represent an important // information. Important = color.New(color.Bold).SprintFunc() // Link colors a message in underlined blue to represent a clickable link. Link = color.New(color.FgBlue, color.Underline).SprintFunc() )
Functions ¶
func WithColors ¶
WithColors sets the use of colors in the logger. By default, whether or not colors are enabled depends on the user's TTY, but this option can be used to force colors to be enabled or disabled.
func WithErrorOutput ¶
WithErrorOutput binds a second writer on the logger, for logging errors.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents a disgo Logger. It writes the output on a given io.Writer and can toggle debug logs and have an error writer.
func (Logger) Debug ¶
func (l Logger) Debug(a ...interface{})
Debug writes a debug log on the logger's standard writer if the debug logs are enabled.
func (Logger) Debugf ¶
Debugf formats according to a format specifier and writes to the logger's standard writer if the debug logs are enabled.
func (Logger) Debugln ¶
func (l Logger) Debugln(a ...interface{})
Debugln writes a debug log on the logger's standard writer if
the debug logs are enabled and appends a newline to its input.
func (Logger) Error ¶
func (l Logger) Error(a ...interface{})
Error writes an error log on the logger's error writer.
func (Logger) Errorf ¶
Errorf formats according to a format specifier and writes to the logger's error writer.
func (Logger) Errorln ¶
func (l Logger) Errorln(a ...interface{})
Errorln writes an error log on the logger's error writer. It appends a newline to its input.
func (Logger) Info ¶
func (l Logger) Info(a ...interface{})
Info writes an info log on the logger's standard writer.