quorum/log
Sai V c215989c10
Quorum geth upgrade to 1.9.7 (#960)
Co-authored-by: amalraj.manigmail.com <amalraj.manigmail.com>
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
Co-authored-by: Flash Sheridan <flash@pobox.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Nguyen Kien Trung <trung.n.k@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Rob Mulholand <rmulholand@8thlight.com>
Co-authored-by: Felföldi Zsolt <zsfelfoldi@gmail.com>
Co-authored-by: soc1c <soc1c@users.noreply.github.com>
Co-authored-by: Rafael Matias <rafael@skyle.net>
Co-authored-by: gary rong <garyrong0905@gmail.com>
Co-authored-by: Lucas Hendren <lhendre2@gmail.com>
Co-authored-by: Ryan Schneider <ryanleeschneider@gmail.com>
Co-authored-by: ywzqwwt <39263032+ywzqwwt@users.noreply.github.com>
Co-authored-by: zcheng9 <zcheng9@hawk.iit.edu>
Co-authored-by: zzy96 <zhou0250@e.ntu.edu.sg>
Co-authored-by: kikilass <36239971+kikilass@users.noreply.github.com>
Co-authored-by: Darrel Herbst <dherbst@gmail.com>
Co-authored-by: Ross <9055337+Chadsr@users.noreply.github.com>
Co-authored-by: Jeffery Robert Walsh <rlxrlps@gmail.com>
Co-authored-by: Marius Kjærstad <sandakersmann@users.noreply.github.com>
Co-authored-by: Piotr Dyraga <piotr.dyraga@keep.network>
Co-authored-by: Guillaume Ballet <gballet@gmail.com>
Co-authored-by: Michael Forney <mforney@mforney.org>
Co-authored-by: Samuel Marks <807580+SamuelMarks@users.noreply.github.com>
2020-04-29 10:50:56 -04:00
..
CONTRIBUTORS Geth 1.7.2 rebase and addition of Istanbul BFT (#207) 2017-10-31 18:24:11 -04:00
LICENSE Geth 1.7.2 rebase and addition of Istanbul BFT (#207) 2017-10-31 18:24:11 -04:00
README.md Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
README_ETHEREUM.md Geth 1.7.2 rebase and addition of Istanbul BFT (#207) 2017-10-31 18:24:11 -04:00
doc.go log: fixes for golint warnings (#16775) 2018-05-22 10:28:43 +03:00
emit_checkpoint.go Quorum raft upgrade v3.3.13 (#887) 2019-12-04 09:24:31 -05:00
format.go Quorum geth upgrade to 1.9.7 (#960) 2020-04-29 10:50:56 -04:00
handler.go cmd, dashboard, log: log collection and exploration (#17097) 2018-07-11 10:59:04 +03:00
handler_glog.go cmd, dashboard, log: log collection and exploration (#17097) 2018-07-11 10:59:04 +03:00
handler_go13.go Geth 1.7.2 rebase and addition of Istanbul BFT (#207) 2017-10-31 18:24:11 -04:00
handler_go14.go Geth 1.7.2 rebase and addition of Istanbul BFT (#207) 2017-10-31 18:24:11 -04:00
logger.go cmd, dashboard, log: log collection and exploration (#17097) 2018-07-11 10:59:04 +03:00
root.go all: library changes for swarm-network-rewrite (#16898) 2018-06-14 11:21:17 +02:00
syslog.go Geth 1.7.2 rebase and addition of Istanbul BFT (#207) 2017-10-31 18:24:11 -04:00

README.md

obligatory xkcd

log15 godoc reference Build Status

Package log15 provides an opinionated, simple toolkit for best-practice logging in Go (golang) that is both human and machine readable. It is modeled after the Go standard library's io and net/http packages and is an alternative to the standard library's log package.

Features

  • A simple, easy-to-understand API
  • Promotes structured logging by encouraging use of key/value pairs
  • Child loggers which inherit and add their own private context
  • Lazy evaluation of expensive operations
  • Simple Handler interface allowing for construction of flexible, custom logging configurations with a tiny API.
  • Color terminal support
  • Built-in support for logging to files, streams, syslog, and the network
  • Support for forking records to multiple handlers, buffering records for output, failing over from failed handler writes, + more

Versioning

The API of the master branch of log15 should always be considered unstable. If you want to rely on a stable API, you must vendor the library.

Importing

import log "github.com/inconshreveable/log15"

Examples

// all loggers can have key/value context
srvlog := log.New("module", "app/server")

// all log messages can have key/value context
srvlog.Warn("abnormal conn rate", "rate", curRate, "low", lowRate, "high", highRate)

// child loggers with inherited context
connlog := srvlog.New("raddr", c.RemoteAddr())
connlog.Info("connection open")

// lazy evaluation
connlog.Debug("ping remote", "latency", log.Lazy{pingRemote})

// flexible configuration
srvlog.SetHandler(log.MultiHandler(
    log.StreamHandler(os.Stderr, log.LogfmtFormat()),
    log.LvlFilterHandler(
        log.LvlError,
        log.Must.FileHandler("errors.json", log.JSONFormat()))))

Will result in output that looks like this:

WARN[06-17|21:58:10] abnormal conn rate                       module=app/server rate=0.500 low=0.100 high=0.800
INFO[06-17|21:58:10] connection open                          module=app/server raddr=10.0.0.1

Breaking API Changes

The following commits broke API stability. This reference is intended to help you understand the consequences of updating to a newer version of log15.

  • 57a084d014d4150152b19e4e531399a7145d1540 - Added a Get() method to the Logger interface to retrieve the current handler
  • 93404652ee366648fa622b64d1e2b67d75a3094a - Record field Call changed to stack.Call with switch to github.com/go-stack/stack
  • a5e7613673c73281f58e15a87d2cf0cf111e8152 - Restored syslog.Priority argument to the SyslogXxx handler constructors

FAQ

The varargs style is brittle and error prone! Can I have type safety please?

Yes. Use log.Ctx:

srvlog := log.New(log.Ctx{"module": "app/server"})
srvlog.Warn("abnormal conn rate", log.Ctx{"rate": curRate, "low": lowRate, "high": highRate})

License

Apache