Giter Site home page Giter Site logo

gelfformatter's Introduction

GelfFormatter

This is a logrus formatter which formats log messages into valid gelf for graylog

This library is hugely based on the graylog gelf library but differs in that it is complaint with 12 factor log principles, which states ...

A twelve-factor app never concerns itself with routing or storage of its output stream.
It should not attempt to write to or manage logfiles.
Instead, each running process writes its event stream, unbuffered, to stdout.
During local development, the developer will view this stream in the foreground of their terminal to observe the app’s behavior.

In staging or production deploys, each process’ stream will be captured by the execution environment, collated together with all other streams from the app, and routed to one or more final destinations for viewing and long-term archival.
These archival destinations are not visible to or configurable by the app, and instead are completely managed by the execution environment.
Open-source log routers (such as Logplex and Fluent) are available for this purpose.

Installation

go get -u github.com/ballad89/gelfFormatter
package main

import (
    "github.com/ballad89/gelfFormatter"
    log "github.com/sirupsen/logrus"
    
)

func main() {

    f, err := gelfFormatter.NewGelfFormatter("application-name")

    if err != nil {
        panic(err)
    }
    log.SetFormatter(f)

    log.SetOutput(os.Stdout)

    log.WithFields(log.Fields{
        "animal": "walrus",
    }).Info("animal")
}
{"version":"1.1","host":"machine.name","short_message":"animal","timestamp":1502245262,"level":6,"_facility":"application-name","_animal":"walrus"}

gelfformatter's People

Contributors

ballad89 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.