A cute and configurable logging library for Go, based on Go 1.21+ log/slog.
Supports emoji decoration, structured output, JSON mode, and custom output writers.
- ✅ Simple API:
Info,Warn,Error - 🧱 Structured logging with key-value pairs
- 🎨 Emoji decorations (optional)
- 🧾 JSON output mode for machine consumption (optional)
- 🌈 Color output in terminal (via
slog.TextHandler) - 🔌 Pluggable output (stdout, file, multiwriter, etc)
go get github.com/ZL-Asica/zlogpackage main
import (
"github.com/ZL-Asica/zlog"
"log/slog"
)
func main() {
zlog.Init(&zlog.Options{
Level: slog.LevelDebug,
Emoji: true,
JSON: false,
})
zlog.Info("System startup complete", "user", "asica")
zlog.Warn("Unusual response time", "duration", "450ms")
zlog.Error("Something went wrong", "code", 500, "reason", "timeout")
}| Option | Type | Description |
|---|---|---|
Level |
slog.Level |
Log level (Debug, Info, Warn, Error) |
Emoji |
bool |
Enable emoji decorations |
JSON |
bool |
Use JSON structured logging |
Writer |
io.Writer |
Output destination (default: os.Stdout) |
ℹ️ System startup complete user=elara
⚠️ Unusual response time duration=450ms
❌ Something went wrong code=500 reason=timeout
Or in JSON mode:
{
"time": "2025-05-29T12:00:00Z",
"level": "INFO",
"msg": "System startup complete",
"user": "asica"
}This project is licensed under the MIT License. See the LICENSE file for details.