Documentation ¶
Index ¶
- Constants
- func Abort(f string, v ...interface{})
- func ColorText(text, color string) string
- func Debug(f string, v ...interface{})
- func Error(f string, v ...interface{})
- func Info(f string, v ...interface{})
- func InitLogger(level string, opts ...LoggerOpts) error
- func RegisterLoggerWriter(name string, loggerCreateFunc LoggerWriterCreateFunc)
- func SetLevel(level int)
- func Warn(f string, v ...interface{})
- type ConsoleWriter
- type FileWriter
- type Logger
- func (l *Logger) Abort(f string, v ...interface{})
- func (l *Logger) Debug(f string, v ...interface{})
- func (l *Logger) Error(f string, v ...interface{})
- func (l *Logger) Info(f string, v ...interface{})
- func (l *Logger) SetFormatter(formatterFunc LoggerFormatterFunc)
- func (l *Logger) SetLevel(level int)
- func (l *Logger) Warn(f string, v ...interface{})
- type LoggerFormatter
- type LoggerFormatterFunc
- type LoggerMsg
- type LoggerOpts
- type LoggerWriter
- type LoggerWriterCreateFunc
Constants ¶
View Source
const ( ConsoleBlack = "\x1b[30m" ConsoleRed = "\x1b[31m" ConsoleGreen = "\x1b[32m" ConsoleYellow = "\x1b[33m" ConsoleBlue = "\x1b[34m" ConsoleMagenta = "\x1b[35m" ConsoleCyan = "\x1b[36m" ConsoleWhite = "\x1b[37m" ConsoleReset = "\x1b[0m" )
View Source
const ( LevelAbort = iota LevelError LevelWarn LevelInfo LevelDebug LoggerConsole = "console" LoggerFile = "file" LogRotateNo = 0 LogRotateLines = 1 LogRotateDaily = 2 LogRotateHour = 3 )
View Source
const TimeFormatter = "2006-01-02 15:04:05.000"
Variables ¶
This section is empty.
Functions ¶
func InitLogger ¶
func InitLogger(level string, opts ...LoggerOpts) error
func RegisterLoggerWriter ¶
func RegisterLoggerWriter(name string, loggerCreateFunc LoggerWriterCreateFunc)
Types ¶
type ConsoleWriter ¶
type ConsoleWriter struct {
// contains filtered or unexported fields
}
func (*ConsoleWriter) Colorful ¶
func (cw *ConsoleWriter) Colorful() bool
func (*ConsoleWriter) Flush ¶
func (cw *ConsoleWriter) Flush()
func (*ConsoleWriter) MatchPrefix ¶
func (cw *ConsoleWriter) MatchPrefix(prefix string) bool
type FileWriter ¶
type FileWriter struct {
// contains filtered or unexported fields
}
func (*FileWriter) Colorful ¶
func (fw *FileWriter) Colorful() bool
func (*FileWriter) Flush ¶
func (fw *FileWriter) Flush()
func (*FileWriter) MatchPrefix ¶
func (fw *FileWriter) MatchPrefix(prefix string) bool
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) SetFormatter ¶
func (l *Logger) SetFormatter(formatterFunc LoggerFormatterFunc)
type LoggerFormatter ¶
type LoggerFormatterFunc ¶
formatter 这个事情貌似不是很合理
type LoggerMsg ¶
type LoggerOpts ¶
type LoggerWriter ¶
type LoggerWriter interface { MatchPrefix(prefix string) bool Colorful() bool Write([]byte) (int, error) Flush() }
func NewConsoleWriter ¶
func NewConsoleWriter(opts LoggerOpts) LoggerWriter
func NewFileWriter ¶
func NewFileWriter(opts LoggerOpts) LoggerWriter
type LoggerWriterCreateFunc ¶
type LoggerWriterCreateFunc func(opts LoggerOpts) LoggerWriter
Click to show internal directories.
Click to hide internal directories.