https://github.com/mdigger/graylog
Support for logging to the Graylog server in golang (slog handler)
https://github.com/mdigger/graylog
go golang graylog slog slog-graylog slog-handler
Last synced: 4 months ago
JSON representation
Support for logging to the Graylog server in golang (slog handler)
- Host: GitHub
- URL: https://github.com/mdigger/graylog
- Owner: mdigger
- License: mit
- Created: 2022-12-06T14:38:56.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-02T13:14:06.000Z (about 3 years ago)
- Last Synced: 2024-06-21T02:32:30.953Z (almost 2 years ago)
- Topics: go, golang, graylog, slog, slog-graylog, slog-handler
- Language: Go
- Homepage: https://pkg.go.dev/github.com/mdigger/graylog
- Size: 39.1 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graylog logger
Package graylog provides support for logging to the Graylog server.
It can send messages to the Graylog server using UDP or TCP.
When using UDP as a transport layer, the messages sent are gzip compressed
and automatically chunked.
```golang
import (
"time"
"github.com/mdigger/graylog"
"golang.org/x/exp/slog"
)
func main() {
// init graylog logger
log, err := graylog.Dial("udp", "localhost:12201")
if err != nil {
panic(err)
}
defer log.Close()
// send debug message with attributes
log.Debug("Test message.\nMore info...",
slog.Any("log", log),
slog.Bool("bool", true),
slog.Time("now", time.Now()),
slog.Group("group",
slog.String("str", "string value"),
slog.Duration("duration", time.Hour/3)),
slog.Any("object", struct {
Text string `json:"text"`
}{Text: "text"}),
)
// register as default
slog.SetDefault(log.Logger)
}
```