LoggerGetting Started
Quick Start
The example below initializes the logger as a lightweight extension over Go’s standard log/slog package with colorized
terminal output enabled.
package main
import (
"log/slog"
"github.com/netlifeguru/logger"
)
func main() {
closer, err := logger.Init(logger.Config{
TerminalOutput: true,
})
if err != nil {
slog.Error(err.Error())
}
defer closer.Close()
slog.Info("hello world")
}
Run:
go mod init example
go get github.com/netlifeguru/logger
go run main.goDuring initialization, the logger automatically creates a log directory and writes structured JSON log files using
daily log rotation.
Example log file:
log/2026-05-11-0001.logExample log entry:
{
"time": "2026-05-11T10:47:36.067863+02:00",
"level": "INFO",
"msg": "hello world"
}Default log fields:
time- log timestamplevel- log severity levelmsg- log message