Documentation ¶
Overview ¶
The colorful and simple logging library
Index ¶
- Variables
- type FdWriter
- type IOStream
- type Logger
- func (l *Logger) Debug() IOStream
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Error() IOStream
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Fatal() IOStream
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) Info() IOStream
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) Output(depth int, prefix Prefix, data string, caller string) error
- func (l *Logger) Recover() func(exit bool)
- func (l *Logger) Trace() IOStream
- func (l *Logger) Tracef(format string, v ...interface{})
- func (l *Logger) Warn() IOStream
- func (l *Logger) Warnf(format string, v ...interface{})
- type Prefix
Constants ¶
This section is empty.
Variables ¶
var ( PanicPrefix = Prefix{ Plain: []byte("[PANIC] "), Color: append(append([]byte{'['}, colorful.Red([]byte("PANIC"))...), []byte("] ")...), File: false, } // FatalPrefix show fatal prefix FatalPrefix = Prefix{ Plain: []byte("[FATAL] "), Color: append(append([]byte{'['}, colorful.Red([]byte("FATAL"))...), []byte("] ")...), File: true, } // ErrorPrefix show error prefix ErrorPrefix = Prefix{ Plain: []byte("[ERROR] "), Color: append(append([]byte{'['}, colorful.Red([]byte("ERROR"))...), []byte("] ")...), File: true, } // WarnPrefix show warn prefix WarnPrefix = Prefix{ Plain: []byte("[WARN] "), Color: append(append([]byte{'['}, colorful.Orange([]byte("WARN"))...), []byte("] ")...), } // InfoPrefix show info prefix InfoPrefix = Prefix{ Plain: []byte("[INFO] "), Color: append(append([]byte{'['}, colorful.Green([]byte("INFO"))...), []byte("] ")...), } // DebugPrefix show info prefix DebugPrefix = Prefix{ Plain: []byte("[DEBUG] "), Color: append(append([]byte{'['}, colorful.Purple([]byte("DEBUG"))...), []byte("] ")...), File: true, } // TracePrefix show info prefix TracePrefix = Prefix{ Plain: []byte("[TRACE] "), Color: append(append([]byte{'['}, colorful.Cyan([]byte("TRACE"))...), []byte("] ")...), } )
Functions ¶
This section is empty.
Types ¶
type IOStream ¶
type IOStream chan<- interface{}
Mainly this just looks cool.
Logger IOStreams are syntactically similar to C++ iostream to stdout: `std::cout << "Words\n"` becomes `logger.Info() <- "Words"`
This may be cool for CGO with C++ (if you're crazy)!
type Logger ¶
type Logger struct { Name string Color bool DebugOut bool Timestamp bool Quiet bool // contains filtered or unexported fields }
Logger defines the underlying storage for single logger.
IOStreams are cached on first call to their functions.
func New ¶
New returns new Logger instance with predefined writer output and automatically detect terminal coloring support
func (*Logger) Fatalf ¶
Fatalf print formatted fatal message to output and quit the application with status 1
func (*Logger) Recover ¶
A function that recovers and writes pretty panic messages. Usage: `defer Recover()(true)` to exit, false argument to continue running.