logrusPushover

package module
v0.0.0-...-ca76031 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 3 Imported by: 0

README

Pushover hook for logrus GoDoc Go Report Card

Send Logrus log message using Pushover on levels:

  • Error
  • Fatal
  • Panic

Installation

go get github.com/toorop/logrus_pushover

Usage

import (
  "log/syslog"
  "github.com/Sirupsen/logrus"
  "github.com/toorop/logrus_pushover"
)

func main() {
hook, err := NewPushoverHook("PUSH_OVER_USER_TOKEN","PUSH_OVER_API_TOKEN")
	if err != nil {
		panic(err)
	}
	msg := "test message"
	log := logrus.New()
	log.Out = ioutil.Discard
	log.Hooks.Add(hook)
	log.WithFields(logrus.Fields{"fied1": "1", "field2": "2"}).Error(msg)
}

async:

import (
  "log/syslog"
  "github.com/Sirupsen/logrus"
  "github.com/toorop/logrus_pushover"
)

func main() {
hook, err := NewPushoverAsyncHook("PUSH_OVER_USER_TOKEN","PUSH_OVER_API_TOKEN")
	if err != nil {
		panic(err)
	}
	msg := "test message"
	log := logrus.New()
	log.Out = ioutil.Discard
	log.Hooks.Add(hook)
	log.WithFields(logrus.Fields{"fied1": "1", "field2": "2"}).Error(msg)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PushoverHook

type PushoverHook struct {
	// contains filtered or unexported fields
}

PushoverHook sends log via Pushover (https://pushover.net/)

func NewPushoverAsyncHook

func NewPushoverAsyncHook(pushoverUserToken, pushoverAPIToken string) (*PushoverHook, error)

NewPushoverAsyncHook init & returns a new async PushoverHook

func NewPushoverHook

func NewPushoverHook(pushoverUserToken, pushoverAPIToken string) (*PushoverHook, error)

NewPushoverHook init & returns a new PushoverHook

func (*PushoverHook) Fire

func (hook *PushoverHook) Fire(entry *logrus.Entry) error

Fire is called when a log event is fired.

func (*PushoverHook) Levels

func (hook *PushoverHook) Levels() []logrus.Level

Levels returns the available logging levels.

func (*PushoverHook) SetMuteDelay

func (hook *PushoverHook) SetMuteDelay(durationStr string) (err error)

SetMuteDelay set muteDelay

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL