mozlogrus

package module
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2017 License: MPL-2.0 Imports: 5 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enable

func Enable(loggerName string)

Enable sets stdout with idiotmatic mozlog formatting

func EnableFormatter

func EnableFormatter(m *MozLogFormatter)

EnableFormatter sets stdout logging with a custom MozLogFormatter

Types

type MozLogFormatter

type MozLogFormatter struct {
	LoggerName string
	Type       string
}

func (*MozLogFormatter) Format

func (m *MozLogFormatter) Format(entry *logrus.Entry) ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL