https://github.com/pnelson/log
Package log implements structured logging helpers.
https://github.com/pnelson/log
Last synced: 6 months ago
JSON representation
Package log implements structured logging helpers.
- Host: GitHub
- URL: https://github.com/pnelson/log
- Owner: pnelson
- License: isc
- Created: 2021-09-05T08:53:50.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-10-19T04:07:29.000Z (almost 5 years ago)
- Last Synced: 2025-10-13T05:13:03.264Z (9 months ago)
- Language: Go
- Homepage: https://pkg.go.dev/github.com/pnelson/log
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# log
Package log implements structured logging helpers.
Levels are supported with the following intended production semantics:
- `DBG` *debug*
- `INF` *machine-actionable*
- `WRN` *human-observable*
- `ERR` *human-actionable*
Handlers are used to format log entry output. The following functions return
loggers with preconfigured handlers. Optionally write your own by implementing
the `log.Handler` interface.
- [NewLogger](https://pkg.go.dev/github.com/pnelson/log#NewLogger)
- [NewTextLogger](https://pkg.go.dev/github.com/pnelson/log#NewTextLogger)
- [NewShellLogger](https://pkg.go.dev/github.com/pnelson/log#NewShellLogger)
- [NewMinimalShellLogger](https://pkg.go.dev/github.com/pnelson/log#NewMinimalShellLogger)
- [NewDiscardLogger](https://pkg.go.dev/github.com/pnelson/log#NewDiscardLogger)
## Usage
```go
package main
import (
"os"
"github.com/pnelson/log"
)
func main() {
loggers := []*log.Logger{
log.NewLogger(os.Stderr, false),
log.NewTextLogger(os.Stderr),
log.NewShellLogger(os.Stderr),
log.NewMinimalShellLogger(os.Stderr),
log.NewDiscardLogger(),
}
for _, l := range loggers {
l.Log(log.ERR, log.M{"foo": "bar"}, "baz/%s", "qux")
}
}
```
