Coder Social home page Coder Social logo

logmatic-go's Introduction

logmatic-go

Link to the Logmatic.io documentation: http://doc.logmatic.io/docs/go

Go helpers to send logs to Logmatic.io based on Logrus lib.

It mainly contains a proper JSON formatter and a TLS socket handler that streams logs directly to Logmatic.io - so no need to use a log shipper if you don't wan't to.

Features

  • Use the library as a wrapper for logrus. Everything is forwarded to Logmatic.io as JSON documents.
  • Metas and extra attributes
  • JSON formatter
  • Secure connection to Logmatic (SSL)

Usage

Use the JSON formatter

To use the JSON formatter, simply associate it.

package main

import (
  log "github.com/sirupsen/logrus"
  "github.com/logmatic/logmatic-go"
)

func main() {
  
	// use JSONFormatter
  	log.SetFormatter(&logmatic.JSONFormatter{})
  	  
	// log an event as usual with logrus
 	log.WithFields(log.Fields{"string": "foo", "int": 1, "float": 1.1 }).Info("My first event from golang to stdout")
}

You should able to see on the console the following output.

{
  "date": "2016-05-10T15:48:47+02:00",
  "float":1.1,
  "int":1,
  "level":"info",
  "message":"My first ssl event from golang to stdout",
  "string":"foo"
}

Stream log straight to Logmatic.io

The Logrus can be coupled to the LogmaticHook as follow:

	// instantiate a new Logger with your Logmatic APIKey
  	log.AddHook(logmatic.NewLogmaticHook("<YOUR_API_KEY>"))
  
	//Don't forget to replace by the one provided on your Logmatic.io's platform.
	// log an event as usual with logrus
 	log.WithFields(log.Fields{"string": "foo", "int": 1, "float": 1.1 }).Info("My second event from golang to Logmatic")
  
}

With this configuration, any log coming from your Go's application will be sent to your platform and will fulfill the same format as described in the previous section.

logmatic.io

Please contact us if you want anything more to be added in this toolset!

logmatic-go's People

Contributors

renaudboutet avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.