Skip to content

Instantly share code, notes, and snippets.

@mbeale
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbeale/7f7ae92bcc1107bcc319 to your computer and use it in GitHub Desktop.
Save mbeale/7f7ae92bcc1107bcc319 to your computer and use it in GitHub Desktop.
Papertrail with Go
package main
import (
// "log"
"log/syslog"
)
func main() {
pt, err := syslog.Dial("udp", "<host>.papertrailapp.com:11111", syslog.LOG_ERR, "My_App_Name")
if err != nil {
panic(err)
}
//log.SetOutput(pt) //optional if you want to send log messages to syslog
//log.Println("Oops. Something went wrong")
//standard messages
pt.Debug("This is a debug message")
pt.Alert("This is an alert message")
//if you want to have your own format
pt.Write([]byte("ERROR HTTP STATUS: 422 Message: You are missing some required fields."))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment