Created
November 16, 2015 16:03
-
-
Save jbuberel/a974beea55baec01ada0 to your computer and use it in GitHub Desktop.
Using Fluentd logger with Go on Google Cloud
This file contains 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
// You'll need to run the following command: | |
// go get github.com/fluent/fluent-logger-golang/fluent | |
// ...before running this code sample with 'go run' | |
package main | |
import ( | |
"runtime" | |
"github.com/fluent/fluent-logger-golang/fluent" | |
) | |
func main() { | |
logger, _ := fluent.New(fluent.Config{}) | |
tag2 := "myapp.errors" | |
defer func() { | |
if e := recover(); e != nil { | |
stack := make([]byte, 1<<16) | |
sz := runtime.Stack(stack, true) | |
stackstr := string(stack[:sz]) | |
var data3 = map[string]string { | |
"app_id": "command-underline", | |
"version": "v2.0.0", | |
"message": "A slightly modified error occurred", | |
"error_message":"This is my error other messages", | |
"function": "main", | |
"exception": stackstr, | |
"environment": "prod", | |
} | |
_ = logger.Post(tag2, data3) | |
} | |
}() | |
panic("something went horribly wrong") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment