123456789101112131415161718192021222324252627 |
- package log
- import (
- "fmt"
- stdlog "log"
- "os"
- )
- // stdoutHandler stdout log handler
- type stdoutHandler struct {
- out *stdlog.Logger
- }
- // NewStdHandler create a stdout log handler
- func NewStdHandler() Handler {
- return &stdoutHandler{out: stdlog.New(os.Stdout, "", stdlog.LstdFlags|stdlog.Lshortfile)}
- }
- // Log stdout loging
- func (h *stdoutHandler) Log(level, msg string) {
- _ = h.out.Output(5, fmt.Sprintf("[%s] %s", level, msg))
- }
- // Close stdout loging
- func (h *stdoutHandler) Close() (err error) {
- return
- }
|