# Packages
No description provided by the author
# README
Structured logging with context support based on slog.
Install
go get github.com/unemil/logger
Compatibility: go >= 1.21
Usage
export LOG_LEVEL=LEVEL
export LOG_FORMAT=FORMAT
export LOG_FILE=FILE
Levels
- TRACE
- DEBUG
- INFO
- WARN
- ERROR
- FATAL
- PANIC
Default: INFO
Formats
- TEXT
- JSON
Default: TEXT
Example
package main
import (
"context"
"errors"
"net/http"
"github.com/unemil/logger"
)
func main() {
logger.Errorf(
logger.Context(context.Background(), "username", "unemil"),
"test",
errors.New(http.StatusText(http.StatusUnauthorized)),
logger.Field("status", http.StatusUnauthorized),
)
// time=2024-07-25T13:25:53+03:00 level=ERROR source=test/main.go:12 msg=test error=Unauthorized status=401 username=unemil
}