go-cloudlog is a client library for Anexia CloudLog.
With a correctly configured Go toolchain:
go get -u github.com/anexia-it/go-cloudlog
package main
import cloudlog "github.com/anexia-it/go-cloudlog"
func main() {
// Init CloudLog client
client, err := cloudlog.NewCloudLog("index", "token")
if err != nil {
panic(err)
}
// Push simple message
client.PushEvent("My first CloudLog event")
// Push document as map
logger.PushEvent(map[string]interface{}{
"timestamp": time.Now(),
"user": "test",
"severity": 1,
"message": "My first CloudLog event",
})
// Push document as map
type Document struct {
Timestamp uint64 `cloudlog:"timestamp"`
User string `cloudlog:"user"`
Severity int `cloudlog:"severity"`
Message string `cloudlog:"message"`
}
logger.PushEvent(&Document{
Timestamp: 1495171849463,
User: "test",
Severity: 1,
Message: "My first CloudLog event",
})
}