A small Go package that gives logrus a cleaner, structured, and visually aligned output style with bracketed tags, optional colors, and multi-output support.
Use it as a drop-in logger with sane defaults, or fully customize formatting, output, and caller behavior using functional options.
Pretty Go Log wraps logrus with a formatter designed for readability:
- Aligned Tag Output. Bracketed tags align to a common column for fast scanning
- Multiple Tag Styles. Default, centered, or right-aligned tag padding
- Multi Output. Console + rotating file output with separate formatters
- Configurable Colors. Colorized levels and tags, dim gray padding
- Caller Awareness. Toggle caller output for warnings and errors
- Environment Config. Use
LOG_LEVEL,LOG_OUTPUT,LOG_FORMATdefaults
go get github.com/canefe/pretty-go-logpackage main
import (
"github.com/canefe/pretty-go-log/logrus/pretty"
)
func main() {
log := pretty.New()
log.Info("[Server] Started on :8080")
log.Warn("[Cache] Miss for key user:123")
}package main
import (
"github.com/canefe/pretty-go-log/logrus/pretty"
"github.com/sirupsen/logrus"
)
func main() {
log := pretty.New(
pretty.WithLevel(logrus.DebugLevel),
pretty.WithOutput(pretty.OutputMulti),
pretty.WithFormat(pretty.FormatPlain),
pretty.WithNamespace("App"),
pretty.WithFile("logs/service.log"),
)
log.Debug("[Init] Starting")
}package main
import (
"github.com/canefe/pretty-go-log/logrus/pretty"
"github.com/sirupsen/logrus"
)
func main() {
formatter := pretty.NewCustomFormatter(
pretty.WithTagStyle(pretty.StyleRight, "."),
pretty.WithBracketPadding(15),
pretty.WithColorBrackets(true),
)
log := pretty.New(
pretty.WithLevel(logrus.InfoLevel),
pretty.WithOutput(pretty.OutputMulti),
pretty.WithCustomFormat(*formatter),
pretty.WithFile("logs/service.log"),
)
log.Info("[API] Request completed")
}package main
import (
"os"
"github.com/canefe/pretty-go-log/logrus/pretty"
)
func main() {
os.Setenv("LOG_LEVEL", "debug")
os.Setenv("LOG_OUTPUT", "console")
os.Setenv("LOG_FORMAT", "plain")
log := pretty.New()
log.Debug("[Env] Logger configured via env vars")
}pretty.OutputConsolepretty.OutputFilepretty.OutputMulti
pretty.FormatRawpretty.FormatPlainpretty.FormatJSON
pretty.WithLevel(level logrus.Level)pretty.WithOutput(output pretty.OutputType)pretty.WithFormat(format pretty.FormatType)pretty.WithNamespace(name string)pretty.WithFile(path string)pretty.WithoutCaller()pretty.WithCustomFormat(formatter pretty.CustomFormatter)
examples/logrus/basicexamples/logrus/custom-configexamples/logrus/env-configexamples/logrus/file-outputexamples/logrus/json-formatexamples/logrus/multi-outputexamples/showcase
