Added log/slog adapter package
This commit is contained in:
parent
ecd852eede
commit
df6107a67e
7 changed files with 685 additions and 1 deletions
32
README.md
32
README.md
|
|
@ -1,3 +1,33 @@
|
|||
# journal
|
||||
|
||||
Native Go output to the systemd journal socket.
|
||||
Native Go output to the [systemd journal socket](https://systemd.io/JOURNAL_NATIVE_PROTOCOL/).
|
||||
See package `journslog` for a [`log/slog`](https://pkg.go.dev/log/slog) adapter.
|
||||
|
||||
Quick start:
|
||||
|
||||
```go
|
||||
import "src.lwithers.me.uk/go/journal"
|
||||
|
||||
func main() {
|
||||
journal.Entry(journal.PriInfo, "hello, world", nil)
|
||||
}
|
||||
```
|
||||
|
||||
The `log/slog` adapter:
|
||||
|
||||
```go
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"src.lwithers.me.uk/go/journal/journslog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
h, err := journslog.NewHandler()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
slog.SetDefault(slog.New(h))
|
||||
slog.Info("hello, world", "attr", "value")
|
||||
}
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue