ggzeng
10/22/2019 - 2:36 AM

logrus txt formatter

package main

import (
    "os"

    "github.com/sirupsen/logrus"
    "github.com/t-tomalak/logrus-easy-formatter"
)

func main() {
    logger := &logrus.Logger{
        Out:   os.Stderr,
        Level: logrus.DebugLevel,
        Formatter: &easy.Formatter{
            TimestampFormat: "2006-01-02 15:04:05",
            LogFormat:       "%time%: [%lvl%] - %msg%",
        },
    }

    logger.Printf("Log message %d %s", 1, "a")
}
// <output>
// 2009-11-10 23:00:00: [INFO] - Log message 1 a