go.mozilla.org/mozlogrus

A logging library which conforms to Mozilla's logging standard for logrus users.


License
MPL-2.0
Install
go get go.mozilla.org/mozlogrus

Documentation

mozlogrus GoDoc

A logging library which conforms to Mozilla's logging standard for logrus.

Installation

go get go.mozilla.org/mozlogrus

Example

Basic Usage

package main

import (
	log "github.com/Sirupsen/logrus"
	"go.mozilla.org/mozlogrus"
)

func init() {
	mozlogrus.Enable("ApplicationName")
}

func main() {
	log.WithFields(log.Fields{
		"animal": "walrus",
		"size":   10,
	}).Info("A group of walrus emerges from the ocean")
}
$ go run mozlogrus.go | jq
{
  "Timestamp": 1487349663973687600,
  "Time": "2017-02-17T16:41:03Z",
  "Type": "app.log",
  "Logger": "ApplicationName",
  "Hostname": "gator3",
  "EnvVersion": "2.0",
  "Pid": 18061,
  "Severity": 4,
  "Fields": {
    "animal": "walrus",
    "msg": "A group of walrus emerges from the ocean",
    "size": 10
  }
}

Custom Log Types

func init() {
    mozlogrus.EnableFormatter(&mozlogrus.MozLogFormatter{
        LoggerName: "ApplicationName",
        Type: "udp datagram",
    })
}