Add axis_timelapse.go
This commit is contained in:
52
axis_timelapse.go
Normal file
52
axis_timelapse.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/getsentry/sentry-go"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"axis_timelapse/cmd"
|
||||
"axis_timelapse/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
||||
zerolog.SetGlobalLevel(zerolog.InfoLevel)
|
||||
|
||||
//// ***** Start Sentry ***** ////
|
||||
log.Info().Msg(config.Project + ": Initializing Error Reporting.")
|
||||
|
||||
sentrySyncTransport := sentry.NewHTTPSyncTransport()
|
||||
sentrySyncTransport.Timeout = time.Second * 3
|
||||
|
||||
err := sentry.Init(sentry.ClientOptions{
|
||||
Dsn: config.SentryDSN,
|
||||
Environment: "Production",
|
||||
Release: config.Project + "@" + config.Version,
|
||||
Debug: false,
|
||||
AttachStacktrace: true,
|
||||
Transport: sentrySyncTransport,
|
||||
BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event {
|
||||
if hint.Context != nil {
|
||||
if req, ok := hint.Context.Value(sentry.RequestContextKey).(*http.Request); ok {
|
||||
log.Debug().Msg(req)
|
||||
}
|
||||
}
|
||||
log.Error().Msg(event)
|
||||
return event
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("["+config.Project+"]: Sentry initialization failed: %v\n", err)
|
||||
}
|
||||
|
||||
// Flush buffered events before the program terminates.
|
||||
// Set the timeout to the maximum duration the program can afford to wait.
|
||||
defer sentry.Flush(2 * time.Second)
|
||||
//// ***** End Sentry ***** ////
|
||||
|
||||
cmd.Execute()
|
||||
}
|
||||
Reference in New Issue
Block a user