jog: github.com/tv42/jog Index | Files | Directories

package jog

import "github.com/tv42/jog"

Jog is a structured logging library outputting JSON messages one per line.

Each logged event will have the following fields:

- Time: ISO 8601 format
- Type: type of the Go variable representing the event
- Data: details of the event

The format for the type is "IMPORTPATH#TYPE", for example "github.com/tv42/jog#unencodable".

Index

Package Files

jog.go

type Config Uses

type Config struct {
    // Destination to which log events will be written.
    Out io.Writer
}

type Logger Uses

type Logger struct {
    // contains filtered or unexported fields
}

A Logger represents a logger that takes Go variables as events and writes them to an io.Writer as JSON. Each logging operation makes a single call to the Writer's Write method and contains one complete log event. For high throughput logging, you may want to use a bufio.Writer. A Logger can be used simultaneously from multiple goroutines, Write calls happen one at a time.

func New Uses

func New(conf *Config) *Logger

New creates a new Logger. Configuration is optional.

func (*Logger) Event Uses

func (l *Logger) Event(data interface{})

Record an event on this Logger. Data may be any value that can be JSON encoded.

Directories

PathSynopsis
example
example/greetings

Package jog imports 6 packages (graph) and is imported by 7 packages. Updated 2016-07-31. Refresh now. Tools for package owners.