Code Monkey home page Code Monkey logo

logruspushover's Introduction

Logrus Pushover Package

A simple wrapper for pushover to use with Logrus, the structured logger for Go. Allows logging messages to be sent over to Pushover service (https://pushover.net/). The user has full control over the log level to be sent to pushover, and the rate of messages sent.

Installation

Please create an API key and user key in Pushover - you need them to send the messages

Sample usage

package main

import (
	"fmt"
	"github.com/razsteinmetz/logrusPushover"
	"github.com/sirupsen/logrus"
	"time"
)

// setup your api key and user key
const apikey = "lognapikey"
const userkey = "long user key"

func main() {
	// note different log level to pushover (Error level) vs Debug level to console
	hook := logrusPushover.NewPushoverHook(userkey, apikey1, true, logrus.ErrorLevel, "", true)
	log := logrus.New()
	log.Hooks.Add(hook)
	log.SetFormatter(&logrus.TextFormatter{
		ForceColors: true,
	})
	// sample messages sent to pushover and console
	log.WithFields(logrus.Fields{"fied1": "1", "field2": "2"}).Error(msg)
	log.WithFields(logrus.Fields{"fied1": "2", "field2": "4"}).Debug(msg)
	log.WithFields(logrus.Fields{"fied1": "3", "field2": "5"}).Info(msg)
	log.Debugln("Debugln message")
	log.Infoln("infoln message")
	log.Errorln("errorln message")
	// give some time for messages to be sent to pushover
	for {
		time.Sleep(5 * time.Second)
	}
}

logruspushover's People

Contributors

razsteinmetz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.