🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

github.com/SkYNewZ/slog-pushover

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/SkYNewZ/slog-pushover

Source
Go Modules
Version
v0.0.2
Version published
Created
Source

slog: Pushover handler

tag Go Version GoDoc Go report License

A Pushover Handler for slog Go library. Inspired from samber' s slog repositories

🚀 Install

go get github.com/SkYNewZ/slog-pushover

Compatibility: go >= 1.21

đź’ˇ Usage

GoDoc: https://pkg.go.dev/github.com/skynewz/slog-pushover

Handler options

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 key

	Message   *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

package main

func 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

📝 License

Copyright © 2023 Quentin Lemaire.

This project is MIT licensed.

FAQs

Package last updated on 04 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts