go-cloudlog
go-cloudlog is a client library for Anexia CloudLog.
Install
With a correctly configured Go toolchain:
1go get -u github.com/anexia-it/go-cloudlog
Quickstart
1package main
2
3import cloudlog "github.com/anexia-it/go-cloudlog"
4
5func main() {
6
7 // Init CloudLog client
8 client, err := cloudlog.NewCloudLog("index", "token")
9 if err != nil {
10 panic(err)
11 }
12
13 // Push simple message
14 client.PushEvent("My first CloudLog event")
15
16 // Push document as map
17 logger.PushEvent(map[string]interface{}{
18 "timestamp": time.Now(),
19 "user": "test",
20 "severity": 1,
21 "message": "My first CloudLog event",
22 })
23
24 // Push document as map
25 type Document struct {
26 Timestamp uint64 `cloudlog:"timestamp"`
27 User string `cloudlog:"user"`
28 Severity int `cloudlog:"severity"`
29 Message string `cloudlog:"message"`
30 }
31 logger.PushEvent(&Document{
32 Timestamp: 1495171849463,
33 User: "test",
34 Severity: 1,
35 Message: "My first CloudLog event",
36 })
37}