logrus_papertrail

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

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

Go to latest
Published: Feb 14, 2018 License: MIT Imports: 6 Imported by: 9

README

Papertrail Hook for Logrus Build Status godoc reference

Papertrail provides hosted log management. Once stored in Papertrail, you can group your logs on various dimensions, search them, and trigger alerts.

In most deployments, you'll want to send logs to Papertrail via their remote_syslog daemon, which requires no application-specific configuration. This hook is intended for relatively low-volume logging, likely in managed cloud hosting deployments where installing remote_syslog is not possible.

Usage

You can find your Papertrail port(Accepting TCP/TLS, UDP) on your Papertrail account page. Substitute it below for YOUR_PAPERTRAIL_PORT.

For YOUR_APP_NAME and YOUR_HOST_NAME, substitute a short strings that will readily identify your application and server in the logs. If you leave YOUR_HOST_NAME empty, papertrail will replace it with your ip.

import (
  log "github.com/sirupsen/logrus"
  "github.com/polds/logrus-papertrail-hook"
)

func main() {

  hook, err := logrus_papertrail.NewPapertrailHook(&logrus_papertrail.Hook{
    Host: "logs.papertrailapp.com",
    Port: YOUR_PAPERTRAIL_PORT,
    Hostname: YOUR_HOST_NAME,
    Appname: YOUR_APP_NAME
  })

  hook.SetLevels([]log.Level{log.ErrorLevel, log.WarnLevel})

  if err == nil {
    log.AddHook(hook)
  }

  log.Warning("Here is you message")

}

2017-04-13-16 32 29-screenshot

Changelog

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hook

type Hook struct {
	// Connection Details
	Host string
	Port int

	// App Details
	Appname  string
	Hostname string
	// contains filtered or unexported fields
}

PapertrailHook to send logs to a logging service compatible with the Papertrail API.

func NewPapertrailHook

func NewPapertrailHook(hook *Hook) (*Hook, error)

NewPapertrailHook creates a UDP hook to be added to an instance of logger.

func NewPapertrailTCPHook

func NewPapertrailTCPHook(hook *Hook) (*Hook, error)

NewPapertrailTCPHook creates a TCP/TLS hook to be added to an instance of logger.

func (*Hook) Fire

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

Fire is called when a log event is fired.

func (*Hook) Levels

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

Levels returns the available logging levels.

func (*Hook) SetLevels

func (hook *Hook) SetLevels(lvs []logrus.Level)

SetLevels specify nessesary levels for this hook.

Jump to

Keyboard shortcuts

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