Documentation ¶
Index ¶
- Constants
- Variables
- func Debug(args ...interface{})
- func Debugf(msg string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(msg string, args ...interface{})
- func Info(args ...interface{})
- func Infof(msg string, args ...interface{})
- func Log(level Level, offset int, args ...interface{})
- func Logf(level Level, offset int, msg string, args ...interface{})
- func NewConsoleWriter(cfg ConsoleConfig, out io.Writer) io.Writer
- func Trace(args ...interface{})
- func Tracef(msg string, args ...interface{})
- func Warn(args ...interface{})
- func Warnf(msg string, args ...interface{})
- type ConsoleConfig
- type ConsoleWriter
- type Level
- type Logger
- func (l *Logger) Debug(args ...interface{})
- func (l *Logger) Debugf(msg string, args ...interface{})
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(msg string, args ...interface{})
- func (l *Logger) Info(args ...interface{})
- func (l *Logger) Infof(msg string, args ...interface{})
- func (l *Logger) Log(level Level, offset int, args ...interface{})
- func (l *Logger) Logf(level Level, offset int, msg string, args ...interface{})
- func (l *Logger) Trace(args ...interface{})
- func (l *Logger) Tracef(msg string, args ...interface{})
- func (l *Logger) Warn(args ...interface{})
- func (l *Logger) Warnf(msg string, args ...interface{})
- func (l *Logger) WithOptions(opts ...Option) *Logger
- type Option
- type RotateFileConfig
- type RotateFileMode
- type RotateFileWriter
- type Writer
Constants ¶
const ( Reset = "\033[0m" Red = "\033[1;31m" Green = "\033[1;32m" Yellow = "\033[1;33m" Blue = "\033[1;34m" Magenta = "\033[1;35m" Cyan = "\033[1;36m" White = "\033[1;37m" BlueBold = "\033[34;1m" MagentaBold = "\033[35;1m" RedBold = "\033[31;1m" YellowBold = "\033[33;1m" )
Variables ¶
var DefaultLogger = New()
var DefaultWriter = os.Stdout
Functions ¶
func NewConsoleWriter ¶
func NewConsoleWriter(cfg ConsoleConfig, out io.Writer) io.Writer
Types ¶
type ConsoleConfig ¶
type ConsoleConfig struct {
Colorful bool
}
type ConsoleWriter ¶
type ConsoleWriter struct {
// contains filtered or unexported fields
}
type Level ¶
type Level int8
A Level is a logging priority. Higher levels are more important.
func ParseLevel ¶
ParseLevel parses a level based on the lower-case or all-caps ASCII representation of the log level. If the provided ASCII representation is invalid an error is returned.
This is particularly useful when dealing with text input to configure log levels.
func (Level) MarshalText ¶
MarshalText marshals the Level to text. Note that the text representation drops the -Level suffix (see example).
func (*Level) UnmarshalText ¶
UnmarshalText unmarshals text to a level. Like MarshalText, UnmarshalText expects the text representation of a Level to drop the -Level suffix.
In particular, this makes it easy to configure logging levels using YAML, TOML, or JSON files.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) WithOptions ¶
WithOptions returns a new Logger with the given Options. It does not modify the original Logger.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
An Option configures a Logger.
func AddCallerSkip ¶
func WithCaller ¶
func WithClock ¶
WithClock specifies the clock used by the logger to determine the current time for logged entries. Defaults to the system clock with time.Now.
func WithOutput ¶
type RotateFileConfig ¶
type RotateFileConfig struct { FileName string Mode RotateFileMode MaxDays int Clock clock.Clock }
type RotateFileMode ¶
type RotateFileMode string
const ( RotateFileModeNone RotateFileMode = "" RotateFileModeDaily RotateFileMode = "daily" )
type RotateFileWriter ¶
type RotateFileWriter struct {
// contains filtered or unexported fields
}
func NewRotateFileWriter ¶
func NewRotateFileWriter(cfg RotateFileConfig) *RotateFileWriter
func (*RotateFileWriter) Close ¶
func (fw *RotateFileWriter) Close() error
func (*RotateFileWriter) Init ¶
func (fw *RotateFileWriter) Init()
func (*RotateFileWriter) Rotate ¶
func (fw *RotateFileWriter) Rotate() error