如何登录滚动条



rollbar.com 网站上有一个示例 Go 代码,它应该说明如何将日志项发送到 Rollbar:

package main
import (
"github.com/rollbar/rollbar-go"
)
func main() {
rollbar.SetToken("6a...16")
rollbar.SetEnvironment("production")                 // defaults to "development"
rollbar.SetCodeVersion("v2")                         // optional Git hash/branch/tag (required for GitHub integration)
rollbar.SetServerHost("web.1")                       // optional override; defaults to hostname
rollbar.SetServerRoot("github.com/heroku/myproject") // path of project (required for GitHub integration and non-project stacktrace collapsing)
result, err := DoSomething()
if err != nil {
rollbar.Critical(err)
}
rollbar.Info("Message body goes here")
rollbar.Wait()
}

遗憾的是,此代码无法编译,因为调用的DoSomething函数不存在。但即使我解决了这个问题并创建了一个名为DoSomething的函数,它仍然不会将任何内容记录到 Rollbar 中。

我应该如何从 Go 代码登录滚动条?

这是一个接近最小的代码,从 Go 代码登录到 Rollbar:

package main
import (
"github.com/rollbar/rollbar-go"
"time"
)
func main() {
rollbar.SetToken("7135d6a90b1c4a6d9dbc736fb97d3816")
rollbar.SetEnvironment("production")                 // defaults to "development"
rollbar.Info("Message body goes here")
rollbar.WrapAndWait(DoSomething)
}
func DoSomething() {
var timer *time.Timer = nil
timer.Reset(10) // this will panic
}

最新更新