Last active
November 5, 2015 00:38
-
-
Save mohae/2522a9fefbf25950a9b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "github.com/segmentio/go-loggly" | |
| "net/http" | |
| ) | |
| const logglyToken = "insert-your-loggly-customer-token-here" | |
| var log loggly.Client | |
| // PRIMARY ROUTE HANDLER | |
| func PrimaryH(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintf(w, "Serving handler2 at: [ %s ]", r.URL.Path[1:]) | |
| log.Alert("Testing alert inside handler...") | |
| } | |
| // TEST ROUTE HANDLER | |
| func TestH(w http.ResponseWriter, r *http.Request) { | |
| LogglyLog("Testing handler2() pre") | |
| fmt.Fprintf(w, "Serving handler2 at: [ %s ]", r.URL.Path[1:]) | |
| LogglyLog("Testing handler2() post") | |
| } | |
| // Custom LogglyLog function | |
| func LogglyLog(m string) { | |
| fmt.Println("LogglyLog() called with ", m) | |
| log.Alert(m) | |
| } | |
| func main() { | |
| log = loggly.New(logglyToken) | |
| LogglyLog("Testing LogglyLog() from main() PRE") | |
| http.HandleFunc("/test", TestH) | |
| http.HandleFunc("/", PrimaryH) | |
| http.ListenAndServe(":8080", nil) | |
| LogglyLog("Testing LogglyLog() from main() POST") // This won’t fire! | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment