Documentation ¶
Overview ¶
Package mlog is simple logging module for go, with a rotating file feature and console logging.
Index ¶
- Constants
- Variables
- func Error(err error)
- func Fatal(a ...interface{})
- func FatalIfError(err error)
- func Fatalf(format string, a ...interface{})
- func IfError(err error)
- func Info(format string, a ...interface{})
- func Start(level LogLevel, path string)
- func StartEx(level LogLevel, path string, maxBytes, backupCount int)
- func Stop() error
- func Sync()
- func Trace(format string, a ...interface{})
- func Warning(format string, a ...interface{})
- type LogLevel
- type RotatingFileHandler
Constants ¶
View Source
const BackupCount int = 10
View Source
const MaxBytes int = 10 * 1024 * 1024
Variables ¶
View Source
var DefaultFlags = log.Ldate | log.Ltime | log.Lshortfile
DefaultFlags used by created loggers
View Source
var Logger mlog
Functions ¶
func Fatal ¶
func Fatal(a ...interface{})
Fatal writes to the Fatal destination and exits with an error 255 code
func FatalIfError ¶
func FatalIfError(err error)
FatalIfError is a shortcut function for log.Fatalf if error and exits with an error 255 code
func Fatalf ¶
func Fatalf(format string, a ...interface{})
Fatalf writes to the Fatal destination and exits with an error 255 code
Types ¶
type RotatingFileHandler ¶
type RotatingFileHandler struct {
// contains filtered or unexported fields
}
RotatingFileHandler writes log a file, if file size exceeds maxBytes, it will backup current file and open a new one.
max backup file number is set by backupCount, it will delete oldest if backups too many.
func NewRotatingFileHandler ¶
func NewRotatingFileHandler(fileName string, maxBytes int, backupCount int) (*RotatingFileHandler, error)
NewRotatingFileHandler creates dirs and opens the logfile
func (*RotatingFileHandler) Close ¶
func (h *RotatingFileHandler) Close() error
Close simply closes the File
Click to show internal directories.
Click to hide internal directories.