logrus_papertrail

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2015 License: MIT, Apache-2.0 Imports: 5 Imported by: 0

README

Papertrail Hook for Logrus

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 UDP port on your Papertrail account page. Substitute it below for YOUR_PAPERTRAIL_UDP_PORT.

For YOUR_APP_NAME, substitute a short string that will readily identify your application or service in the logs.

import (
  "log/syslog"
  "github.com/Sirupsen/logrus"
  "github.com/Sirupsen/logrus/hooks/papertrail"
)

func main() {
  log       := logrus.New()
  hook, err := logrus_papertrail.NewPapertrailHook("logs.papertrailapp.com", YOUR_PAPERTRAIL_UDP_PORT, YOUR_APP_NAME)

  if err == nil {
    log.Hooks.Add(hook)
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PapertrailHook

type PapertrailHook struct {
	Host    string
	Port    int
	AppName string
	UDPConn net.Conn
}

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

func NewPapertrailHook

func NewPapertrailHook(host string, port int, appName string) (*PapertrailHook, error)

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

func (*PapertrailHook) Fire

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

Fire is called when a log event is fired.

func (*PapertrailHook) Levels

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

Levels returns the available logging levels.

Jump to

Keyboard shortcuts

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