logrus_papertrail

package module
v2.0.0-...-dfa4a9f Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2015 License: MIT Imports: 5 Imported by: 6

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 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"
  "gopkg.in/polds/logrus-papertrail-hook.v2"
)

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

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

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 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.

Jump to

Keyboard shortcuts

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