Skip to content

Instantly share code, notes, and snippets.

@jbuberel
Created November 16, 2015 16:03
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 jbuberel/a974beea55baec01ada0 to your computer and use it in GitHub Desktop.
Save jbuberel/a974beea55baec01ada0 to your computer and use it in GitHub Desktop.
Using Fluentd logger with Go on Google Cloud
// 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