1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package myth
- import (
- "io"
- "log"
- )
- // Logger logger
- type Logger struct {
- logger *log.Logger
- }
- // NewLogger new logger
- func NewLogger(out io.Writer) *Logger {
- logger := log.New(out, "[INFO]", log.Ldate|log.Ltime)
- return &Logger{logger: logger}
- }
- // Info log info
- func (l *Logger) Info(v ...interface{}) {
- l.logger.SetPrefix("[INFO]")
- l.logger.Println(v...)
- }
- // Debug log debug
- func (l *Logger) Debug(v ...interface{}) {
- l.logger.SetPrefix("[DEBUG]")
- l.logger.Println(v...)
- }
- // Warn log Warn
- func (l *Logger) Warn(v ...interface{}) {
- l.logger.SetPrefix("[Warn]")
- l.logger.Println(v...)
- }
- // Err log Err
- func (l *Logger) Err(v ...interface{}) {
- l.logger.SetPrefix("[Err]")
- l.logger.Println(v...)
- }
- // Alert log Alert
- func (l *Logger) Alert(v ...interface{}) {
- l.logger.SetPrefix("[Alert]")
- l.logger.Println(v...)
- }
|