add NewWriter func

master v0.0.1
hans 6 years ago
parent 81fe4e614a
commit e5e74f063d
  1. 6
      filelog.go
  2. 14
      gokit.go

@ -84,9 +84,9 @@ func NewFileLogger(path, name string, flushInterval time.Duration, fileSplitSize
}
func (w *mFileLogger) flushDaemon() {
//for _ = range time.NewTicker(w.flushInterval).C {
// w.flush()
//}
for _ = range time.NewTicker(w.flushInterval).C {
w.flush()
}
}
func (w *mFileLogger) flush() {

@ -2,6 +2,7 @@ package logkit
import (
"fmt"
"io"
"time"
)
@ -189,3 +190,16 @@ func Errorf(format string, args ...interface{}) {
write(LevelError, fmt.Sprintf(format, args...))
}
}
func NewLogWriter(level Level) io.Writer {
return &stdWriter{level}
}
type stdWriter struct {
level Level
}
func (this *stdWriter) Write(data []byte) (int, error) {
write(this.level, string(data))
return len(data), nil
}

Loading…
Cancel
Save