mirror of https://github.com/poanetwork/quorum.git
c3c479d2aa
# Conflicts: # .github/CODEOWNERS # .travis.yml # README.md # VERSION # accounts/abi/argument.go # accounts/abi/bind/backends/simulated.go # accounts/abi/bind/bind_test.go # accounts/abi/event_test.go # accounts/abi/numbers.go # accounts/abi/numbers_test.go # accounts/abi/reflect.go # accounts/accounts.go # accounts/keystore/keystore.go # accounts/keystore/keystore_wallet.go # accounts/usbwallet/internal/trezor/trezor.go # accounts/usbwallet/ledger.go # accounts/usbwallet/wallet.go # appveyor.yml # build/ci.go # build/goimports.sh # cmd/ethkey/generate.go # cmd/ethkey/inspect.go # cmd/ethkey/main.go # cmd/ethkey/message.go # cmd/ethkey/utils.go # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/main.go # cmd/geth/misccmd.go # cmd/geth/usage.go # cmd/p2psim/main.go # cmd/puppeth/genesis.go # cmd/puppeth/module_dashboard.go # cmd/puppeth/wizard_faucet.go # cmd/puppeth/wizard_genesis.go # cmd/puppeth/wizard_netstats.go # cmd/puppeth/wizard_node.go # cmd/puppeth/wizard_wallet.go # cmd/swarm/config.go # cmd/swarm/config_test.go # cmd/swarm/db.go # cmd/swarm/hash.go # cmd/swarm/main.go # cmd/swarm/manifest.go # cmd/swarm/run_test.go # cmd/swarm/upload.go # cmd/swarm/upload_test.go # cmd/utils/flags.go # cmd/wnode/main.go # common/bytes.go # common/compiler/solidity.go # common/hexutil/hexutil.go # common/math/big.go # common/math/integer.go # common/mclock/mclock.go # common/types.go # common/types_template.go # consensus/clique/clique.go # consensus/consensus.go # consensus/ethash/algorithm.go # consensus/ethash/consensus.go # consensus/ethash/ethash.go # containers/vagrant/Vagrantfile # contracts/ens/ens_test.go # core/asm/compiler.go # core/asm/lexer.go # core/block_validator.go # core/blockchain.go # core/blockchain_test.go # core/chain_makers.go # core/database_util.go # core/database_util_test.go # core/events.go # core/genesis.go # core/genesis_alloc.go # core/genesis_test.go # core/headerchain.go # core/rawdb/accessors_chain.go # core/rawdb/accessors_indexes.go # core/rawdb/accessors_metadata.go # core/rawdb/schema.go # core/state/state_test.go # core/state/statedb.go # core/state/sync.go # core/state_processor.go # core/state_transition.go # core/tx_journal.go # core/tx_list.go # core/tx_pool.go # core/tx_pool_test.go # core/types.go # core/types/block.go # core/types/block_test.go # core/types/gen_receipt_json.go # core/types/log.go # core/types/receipt.go # core/types/transaction.go # core/types/transaction_signing.go # core/types/transaction_signing_test.go # core/types/transaction_test.go # core/vm/errors.go # core/vm/evm.go # core/vm/gas.go # core/vm/gas_table.go # core/vm/instructions.go # core/vm/instructions_test.go # core/vm/interface.go # core/vm/interpreter.go # core/vm/intpool.go # core/vm/jump_table.go # core/vm/logger.go # core/vm/logger_test.go # core/vm/memory_table.go # core/vm/opcodes.go # core/vm/runtime/env.go # core/vm/runtime/runtime.go # crypto/crypto.go # crypto/crypto_test.go # eth/api.go # eth/api_backend.go # eth/api_tracer.go # eth/backend.go # eth/config.go # eth/downloader/downloader.go # eth/downloader/queue.go # eth/downloader/statesync.go # eth/filters/filter.go # eth/filters/filter_system.go # eth/filters/filter_system_test.go # eth/gen_config.go # eth/handler.go # eth/handler_test.go # eth/helper_test.go # eth/protocol.go # eth/sync.go # eth/tracers/internal/tracers/4byte_tracer.js # eth/tracers/internal/tracers/assets.go # eth/tracers/tracer_test.go # eth/tracers/tracers_test.go # ethclient/ethclient.go # ethdb/database.go # ethdb/interface.go # ethdb/memory_database.go # ethstats/ethstats.go # event/feed.go # internal/ethapi/api.go # internal/ethapi/backend.go # internal/guide/guide_test.go # internal/web3ext/web3ext.go # les/api_backend.go # les/backend.go # les/fetcher.go # les/handler.go # les/helper_test.go # les/odr_requests.go # les/odr_test.go # les/retrieve.go # les/server.go # les/serverpool.go # light/lightchain.go # light/odr_test.go # light/postprocess.go # light/txpool.go # log/README.md # log/doc.go # log/format.go # log/handler.go # log/logger.go # log/root.go # metrics/exp/exp.go # metrics/influxdb/influxdb.go # metrics/metrics.go # metrics/resetting_timer.go # metrics/resetting_timer_test.go # metrics/timer_test.go # miner/worker.go # mobile/accounts.go # mobile/ethereum.go # mobile/geth.go # node/config.go # node/doc.go # p2p/discover/database.go # p2p/discover/database_test.go # p2p/discover/table.go # p2p/discover/table_test.go # p2p/discover/udp.go # p2p/discover/udp_test.go # p2p/discv5/udp.go # p2p/enr/enr.go # p2p/enr/enr_test.go # p2p/enr/entries.go # p2p/protocols/protocol.go # p2p/protocols/protocol_test.go # p2p/rlpx_test.go # p2p/server.go # p2p/simulations/adapters/docker.go # p2p/simulations/adapters/exec.go # p2p/simulations/adapters/inproc.go # p2p/simulations/adapters/types.go # p2p/simulations/http.go # p2p/simulations/http_test.go # p2p/simulations/mocker.go # p2p/simulations/network.go # p2p/simulations/network_test.go # p2p/testing/protocolsession.go # params/bootnodes.go # params/config.go # params/denomination.go # params/gas_table.go # params/protocol_params.go # params/version.go # rpc/http.go # rpc/json.go # rpc/utils.go # signer/core/api.go # swarm/api/api.go # swarm/api/api_test.go # swarm/api/client/client.go # swarm/api/client/client_test.go # swarm/api/config.go # swarm/api/config_test.go # swarm/api/filesystem.go # swarm/api/filesystem_test.go # swarm/api/http/error.go # swarm/api/http/error_templates.go # swarm/api/http/error_test.go # swarm/api/http/roundtripper.go # swarm/api/http/server.go # swarm/api/http/server_test.go # swarm/api/http/templates.go # swarm/api/manifest.go # swarm/api/manifest_test.go # swarm/api/storage.go # swarm/api/storage_test.go # swarm/api/uri.go # swarm/api/uri_test.go # swarm/fuse/fuse_dir.go # swarm/fuse/fuse_file.go # swarm/fuse/swarmfs.go # swarm/fuse/swarmfs_test.go # swarm/fuse/swarmfs_unix.go # swarm/fuse/swarmfs_util.go # swarm/metrics/flags.go # swarm/network/depo.go # swarm/network/forwarding.go # swarm/network/hive.go # swarm/network/kademlia/address.go # swarm/network/kademlia/kaddb.go # swarm/network/kademlia/kademlia.go # swarm/network/kademlia/kademlia_test.go # swarm/network/messages.go # swarm/network/protocol.go # swarm/network/syncdb.go # swarm/network/syncdb_test.go # swarm/network/syncer.go # swarm/services/swap/swap.go # swarm/services/swap/swap/swap.go # swarm/storage/chunker.go # swarm/storage/chunker_test.go # swarm/storage/common_test.go # swarm/storage/database.go # swarm/storage/dbstore.go # swarm/storage/dbstore_test.go # swarm/storage/dpa.go # swarm/storage/dpa_test.go # swarm/storage/localstore.go # swarm/storage/memstore.go # swarm/storage/netstore.go # swarm/storage/pyramid.go # swarm/storage/swarmhasher.go # swarm/storage/types.go # swarm/swarm.go # swarm/swarm_test.go # swarm/testutil/http.go # tests/block_test_util.go # tests/difficulty_test.go # tests/init.go # tests/state_test_util.go # tests/transaction_test.go # tests/util.go # tests/vm_test_util.go # trie/database.go # trie/encoding.go # trie/hasher.go # trie/iterator.go # trie/proof.go # trie/proof_test.go # trie/secure_trie.go # trie/sync.go # trie/sync_test.go # trie/trie.go # vendor/github.com/docker/docker/pkg/reexec/command_linux.go # vendor/github.com/docker/docker/pkg/reexec/command_unix.go # vendor/github.com/docker/docker/pkg/reexec/command_unsupported.go # vendor/github.com/docker/docker/pkg/reexec/command_windows.go # vendor/github.com/docker/docker/pkg/reexec/reexec.go # vendor/github.com/eapache/channels/.gitignore # vendor/github.com/eapache/queue/.gitignore # vendor/github.com/naoina/toml/encode.go # vendor/github.com/naoina/toml/parse.go # vendor/github.com/naoina/toml/parse.peg # vendor/github.com/naoina/toml/parse.peg.go # vendor/github.com/rcrowley/go-metrics/.gitignore # vendor/github.com/rcrowley/go-metrics/.travis.yml # vendor/github.com/rcrowley/go-metrics/README.md # vendor/github.com/rcrowley/go-metrics/counter.go # vendor/github.com/rcrowley/go-metrics/debug.go # vendor/github.com/rcrowley/go-metrics/ewma.go # vendor/github.com/rcrowley/go-metrics/exp/exp.go # vendor/github.com/rcrowley/go-metrics/gauge.go # vendor/github.com/rcrowley/go-metrics/gauge_float64.go # vendor/github.com/rcrowley/go-metrics/graphite.go # vendor/github.com/rcrowley/go-metrics/healthcheck.go # vendor/github.com/rcrowley/go-metrics/histogram.go # vendor/github.com/rcrowley/go-metrics/json.go # vendor/github.com/rcrowley/go-metrics/log.go # vendor/github.com/rcrowley/go-metrics/meter.go # vendor/github.com/rcrowley/go-metrics/metrics.go # vendor/github.com/rcrowley/go-metrics/opentsdb.go # vendor/github.com/rcrowley/go-metrics/registry.go # vendor/github.com/rcrowley/go-metrics/runtime.go # vendor/github.com/rcrowley/go-metrics/sample.go # vendor/github.com/rcrowley/go-metrics/syslog.go # vendor/github.com/rcrowley/go-metrics/timer.go # vendor/github.com/rcrowley/go-metrics/writer.go # vendor/github.com/syndtr/goleveldb/leveldb/db.go # vendor/golang.org/x/sys/unix/mksysnum_linux.pl # vendor/golang.org/x/sys/unix/types_linux.go # vendor/vendor.json # whisper/shhclient/client.go # whisper/whisperv5/api.go # whisper/whisperv5/peer_test.go # whisper/whisperv5/whisper.go # whisper/whisperv6/api.go # whisper/whisperv6/peer_test.go # whisper/whisperv6/whisper.go |
||
---|---|---|
.. | ||
term | ||
CONTRIBUTORS | ||
LICENSE | ||
README.md | ||
README_ETHEREUM.md | ||
doc.go | ||
emit_checkpoint.go | ||
format.go | ||
handler.go | ||
handler_glog.go | ||
handler_go13.go | ||
handler_go14.go | ||
logger.go | ||
root.go | ||
syslog.go |
README.md
log15
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 theLogger
interface to retrieve the current handler - 93404652ee366648fa622b64d1e2b67d75a3094a -
Record
fieldCall
changed tostack.Call
with switch togithub.com/go-stack/stack
- a5e7613673c73281f58e15a87d2cf0cf111e8152 - Restored
syslog.Priority
argument to theSyslogXxx
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