Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skynewz/slog-pushover
Pushover handler for slog logger
https://github.com/skynewz/slog-pushover
go golang log logger slog structured-logging
Last synced: about 7 hours ago
JSON representation
Pushover handler for slog logger
- Host: GitHub
- URL: https://github.com/skynewz/slog-pushover
- Owner: SkYNewZ
- License: mit
- Created: 2023-11-22T21:58:03.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-07-29T14:17:55.000Z (3 months ago)
- Last Synced: 2024-08-04T10:02:58.232Z (3 months ago)
- Topics: go, golang, log, logger, slog, structured-logging
- Language: Go
- Homepage: https://pkg.go.dev/github.com/SkYNewZ/slog-pushover
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# slog: Pushover handler
[![tag](https://img.shields.io/github/tag/skynewz/slog-pushover.svg)](https://github.com/skynewz/slog-pushover/releases)
![Go Version](https://img.shields.io/badge/Go-%3E%3D%201.21-%23007d9c)
[![GoDoc](https://pkg.go.dev/badge/github.com/skynewz/slog-pushover)](https://pkg.go.dev/github.com/skynewz/slog-pushover)
[![Go report](https://goreportcard.com/badge/github.com/skynewz/slog-pushover)](https://goreportcard.com/report/github.com/skynewz/slog-pushover)
[![License](https://img.shields.io/github/license/skynewz/slog-pushover)](./LICENSE)A [Pushover](https://pushover.net/) Handler for [slog](https://pkg.go.dev/log/slog) Go library. Inspired
from [samber](https://github.com/samber)'
s [slog repositories](https://github.com/samber?tab=repositories&q=slog&type=source&language=go&sort=name)## 🚀 Install
```sh
go get github.com/SkYNewZ/slog-pushover
```**Compatibility**: go >= 1.21
## 💡 Usage
GoDoc: [https://pkg.go.dev/github.com/skynewz/slog-pushover](https://pkg.go.dev/github.com/skynewz/slog-pushover)
### Handler options
```go
type Options struct {
Level slog.Leveler // minimum level of messages to log (default: slog.LevelDebug)Token string // Pushover application token
Recipient string // Pushover user/group keyMessage *pushover.Message // optional: customize Pushover message. 'Message' will be replaced by the log message
Converter Converter // optional: customize Pushover message builder// optional: see slog.HandlerOptions
AddSource bool
ReplaceAttr func(groups []string, a slog.Attr) slog.Attr
}
```### Example
```go
package mainfunc main() {
handler := slogpushover.NewHandler(&slogpushover.Options{
Level: slog.LevelDebug,
Token: os.Getenv("PUSHOVER_TOKEN"),
Recipient: os.Getenv("PUSHOVER_RECIPIENT"),
Message: nil, // You can customize the message details
Converter: nil,
AddSource: true,
ReplaceAttr: nil,
})logger := slog.New(handler)
logger = logger.With("release", "v1.0.0")logger.
With(
slog.Group("user",
slog.String("id", "user-123"),
slog.Time("created_at", time.Now().AddDate(0, 0, -1)),
),
).
With("environment", "dev").
With("error", fmt.Errorf("an error")).
Error("A message")
}
```## 👤 Contributors
![Contributors](https://contrib.rocks/image?repo=skynewz/slog-pushover)
## 📝 License
Copyright © 2023 [Quentin Lemaire](https://github.com/SkYNewZ).
This project is [MIT](./LICENSE) licensed.