noxer / go-cloudlog

CloudLog go client library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-cloudlog

GoDoc Build Status codecov Go Report Card

go-cloudlog is a client library for Anexia CloudLog.

Install

With a correctly configured Go toolchain:

go get -u github.com/anexia-it/go-cloudlog

Quickstart

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",
  })
}

About

CloudLog go client library

License:MIT License


Languages

Language:Go 100.0%