Documentation ¶
Index ¶
- func FlushLogger()
- func SetLevel(level LogLevel)
- type ConsoleWriter
- type DateType
- type DateWriter
- type HourWriter
- type LogLevel
- type LogWriter
- type Logger
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) IsConsoleWriter() bool
- func (l *Logger) SetConsole()
- func (l *Logger) SetDayRoller(logpath string, num int) error
- func (l *Logger) SetFileRoller(logpath string, num int, sizeMB int) error
- func (l *Logger) SetHourRoller(logpath string, num int) error
- func (l *Logger) SetLogName(name string)
- func (l *Logger) SetWriter(w LogWriter)
- func (l *Logger) Warn(v ...interface{})
- func (l *Logger) Warnf(format string, v ...interface{})
- type RollFileWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConsoleWriter ¶
type ConsoleWriter struct { }
ConsoleWriter writes the logs to the console.
func (*ConsoleWriter) NeedPrefix ¶
func (w *ConsoleWriter) NeedPrefix() bool
NeedPrefix shows whether needs the prefix for the console writer.
func (*ConsoleWriter) Write ¶
func (w *ConsoleWriter) Write(v []byte)
type DateWriter ¶
type DateWriter struct {
// contains filtered or unexported fields
}
DateWriter rotate logs by date.
func NewDateWriter ¶
func NewDateWriter(logpath, name string, dateType DateType, num int) *DateWriter
NewDateWriter returns a writer which keeps logs in hours or day format.
func (*DateWriter) NeedPrefix ¶
func (w *DateWriter) NeedPrefix() bool
NeedPrefix shows whether needs prefix info for DateWriter or not.
func (*DateWriter) SetPrefix ¶
func (w *DateWriter) SetPrefix(enable bool)
func (*DateWriter) Write ¶
func (w *DateWriter) Write(v []byte)
Write method implement for the DateWriter
type LogLevel ¶
type LogLevel uint8
LogLevel is uint8 type
func StringToLevel ¶
StringToLevel turns string to LogLevel
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the struct with name and wirter.
func (*Logger) Debug ¶
func (l *Logger) Debug(v ...interface{})
Debug logs interface in debug loglevel.
func (*Logger) Error ¶
func (l *Logger) Error(v ...interface{})
Error logs interface in Error loglevel
func (*Logger) IsConsoleWriter ¶
IsConsoleWriter returns whether is consoleWriter or not.
func (*Logger) SetConsole ¶
func (l *Logger) SetConsole()
SetConsole sets the logger with console writer.
func (*Logger) SetDayRoller ¶
SetDayRoller sets the logger to rotate by day, with max num files.
func (*Logger) SetFileRoller ¶
SetFileRoller sets the file rolled by size in MB, with max num of files.
func (*Logger) SetHourRoller ¶
SetHourRoller sets the logger to rotate by hour, with max num files.
type RollFileWriter ¶
type RollFileWriter struct {
// contains filtered or unexported fields
}
RollFileWriter struct for rotate logs by file size.
func NewRollFileWriter ¶
func NewRollFileWriter(logpath, name string, num, sizeMB int) *RollFileWriter
NewRollFileWriter returns a RollFileWriter, rotate logs in sizeMB , and num files are keeped.
func (*RollFileWriter) NeedPrefix ¶
func (w *RollFileWriter) NeedPrefix() bool
NeedPrefix shows need prefix or not.
func (*RollFileWriter) Write ¶
func (w *RollFileWriter) Write(v []byte)
Write for writing []byte to the writter.