Ecosyste.ms: Repos
An open API service providing repository metadata for many open source software ecosystems.
Package Usage: go: github.com/inconshreveable/log15
Package log15 provides an opinionated, simple toolkit for best-practice logging that is
both human and machine readable. It is modeled after the standard library's io and net/http
packages.
This package enforces you to only log key/value pairs. Keys must be strings. Values may be
any type that you like. The default output format is logfmt, but you may also choose to use
JSON instead if that suits you. Here's how you log:
This will output a line that looks like:
To get started, you'll want to import the library:
Now you're ready to start logging:
Because recording a human-meaningful message is common and good practice, the first argument to every
logging method is the value to the *implicit* key 'msg'.
Additionally, the level you choose for a message will be automatically added with the key 'lvl', and so
will the current timestamp with key 't'.
You may supply any additional context as a set of key/value pairs to the logging function. log15 allows
you to favor terseness, ordering, and speed over safety. This is a reasonable tradeoff for
logging functions. You don't need to explicitly state keys/values, log15 understands that they alternate
in the variadic argument list:
If you really do favor your type-safety, you may choose to pass a log.Ctx instead:
Frequently, you want to add context to a logger so that you can track actions associated with it. An http
request is a good example. You can easily create new loggers that have context that is automatically included
with each log line:
This will output a log line that includes the path context that is attached to the logger:
The Handler interface defines where log lines are printed to and how they are formated. Handler is a
single interface that is inspired by net/http's handler interface:
Handlers can filter records, format them, or dispatch to multiple other Handlers.
This package implements a number of Handlers for common logging patterns that are
easily composed to create flexible, custom logging structures.
Here's an example handler that prints logfmt output to Stdout:
Here's an example handler that defers to two other handlers. One handler only prints records
from the rpc package in logfmt to standard out. The other prints records at Error level
or above in JSON formatted output to the file /var/log/service.json
This package implements three Handlers that add debugging information to the
context, CallerFileHandler, CallerFuncHandler and CallerStackHandler. Here's
an example that adds the source file and line number of each logging call to
the context.
This will output a line that looks like:
Here's an example that logs the call stack rather than just the call site.
This will output a line that looks like:
The "%+v" format instructs the handler to include the path of the source file
relative to the compile time GOPATH. The github.com/go-stack/stack package
documents the full list of formatting verbs and modifiers available.
The Handler interface is so simple that it's also trivial to write your own. Let's create an
example handler which tries to write to one handler, but if that fails it falls back to
writing to another handler and includes the error that it encountered when trying to write
to the primary. This might be useful when trying to log over a network socket, but if that
fails you want to log those records to a file on disk.
This pattern is so useful that a generic version that handles an arbitrary number of Handlers
is included as part of this library called FailoverHandler.
Sometimes, you want to log values that are extremely expensive to compute, but you don't want to pay
the price of computing them if you haven't turned up your logging level to a high level of detail.
This package provides a simple type to annotate a logging operation that you want to be evaluated
lazily, just when it is about to be logged, so that it would not be evaluated if an upstream Handler
filters it out. Just wrap any function which takes no arguments with the log.Lazy type. For example:
If this message is not logged for any reason (like logging at the Error level), then
factorRSAKey is never evaluated.
The same log.Lazy mechanism can be used to attach context to a logger which you want to be
evaluated when the message is logged, but not when the logger is created. For example, let's imagine
a game where you have Player objects:
You always want to log a player's name and whether they're alive or dead, so when you create the player
object, you might do:
Only now, even after a player has died, the logger will still report they are alive because the logging
context is evaluated when the logger was created. By using the Lazy wrapper, we can defer the evaluation
of whether the player is alive or not to each log message, so that the log records will reflect the player's
current state no matter when the log message is written:
If log15 detects that stdout is a terminal, it will configure the default
handler for it (which is log.StdoutHandler) to use TerminalFormat. This format
logs records nicely for your terminal, including color-coded output based
on log level.
Becasuse log15 allows you to step around the type system, there are a few ways you can specify
invalid arguments to the logging functions. You could, for example, wrap something that is not
a zero-argument function with log.Lazy or pass a context key that is not a string. Since logging libraries
are typically the mechanism by which errors are reported, it would be onerous for the logging functions
to return errors. Instead, log15 handles errors by making these guarantees to you:
- Any log record containing an error will still be printed with the error explained to you as part of the log record.
- Any log record containing an error will include the context key LOG15_ERROR, enabling you to easily
(and if you like, automatically) detect if any of your logging calls are passing bad values.
Understanding this, you might wonder why the Handler interface can return an error value in its Log method. Handlers
are encouraged to return errors only if they fail to write their log records out to an external source like if the
syslog daemon is not responding. This allows the construction of useful handlers which cope with those failures
like the FailoverHandler.
log15 is intended to be useful for library authors as a way to provide configurable logging to
users of their library. Best practice for use in a library is to always disable all output for your logger
by default and to provide a public Logger instance that consumers of your library can configure. Like so:
Users of your library may then enable it if they like:
The ability to attach context to a logger is a powerful one. Where should you do it and why?
I favor embedding a Logger directly into any persistent object in my application and adding
unique, tracing context keys to it. For instance, imagine I am writing a web browser:
When a new tab is created, I assign a logger to it with the url of
the tab as context so it can easily be traced through the logs.
Now, whenever we perform any operation with the tab, we'll log with its
embedded logger and it will include the tab title automatically:
There's only one problem. What if the tab url changes? We could
use log.Lazy to make sure the current url is always written, but that
would mean that we couldn't trace a tab's full lifetime through our
logs after the user navigate to a new URL.
Instead, think about what values to attach to your loggers the
same way you think about what to use as a key in a SQL database schema.
If it's possible to use a natural key that is unique for the lifetime of the
object, do so. But otherwise, log15's ext package has a handy RandId
function to let you generate what you might call "surrogate keys"
They're just random hex identifiers to use for tracing. Back to our
Tab example, we would prefer to set up our Logger like so:
Now we'll have a unique traceable identifier even across loading new urls, but
we'll still be able to see the tab's current url in the log messages.
For all Handler functions which can return an error, there is a version of that
function which will return no error but panics on failure. They are all available
on the Must object. For example:
All of the following excellent projects inspired the design of this library:
code.google.com/p/log4go
github.com/op/go-logging
github.com/technoweenie/grohl
github.com/Sirupsen/logrus
github.com/kr/logfmt
github.com/spacemonkeygo/spacelog
golang's stdlib, notably io and net/http
https://xkcd.com/927/
10 versions
Latest release: over 1 year ago
736 dependent packages
View more package details: https://packages.ecosyste.ms/registries/proxy.golang.org/packages/github.com/inconshreveable/log15
View more repository details: https://repos.ecosyste.ms/hosts/GitHub/repositories/inconshreveable%2Flog15
Dependent Repos 1,236
sourcegraph/lsif-go 📦
Language Server Indexing Format (LSIF) generator for Go- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 1.89 MB - Last synced: 1 day ago - Pushed: 8 months ago
fragmentsh/ssv Fork of bloxapp/ssv
Secret-Shared-Validator(SSV) for ethereum staking- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 19.5 MB - Last synced: about 1 year ago - Pushed: about 1 year ago
kokizzu/vuls Fork of future-architect/vuls
Vulnerability scanner for Linux/FreeBSD, agentless, written in Go- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 28.3 MB - Last synced: 27 days ago - Pushed: about 1 month ago
dgfug/grafana Fork of grafana/grafana
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.- v0.0.0-20180818164646-67afb5ed74ec go.mod
- v0.0.0-20180818164646-67afb5ed74ec go.sum
Size: 420 MB - Last synced: about 1 year ago - Pushed: about 1 year ago
ekmixon/grafana Fork of grafana/grafana
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.- v0.0.0-20180818164646-67afb5ed74ec go.mod
- v0.0.0-20180818164646-67afb5ed74ec go.sum
Size: 462 MB - Last synced: about 6 hours ago - Pushed: about 7 hours ago
pawanku2/grafana Fork of grafana/grafana
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.- v0.0.0-20180818164646-67afb5ed74ec go.mod
- v0.0.0-20180818164646-67afb5ed74ec go.sum
Size: 490 MB - Last synced: 24 days ago - Pushed: 26 days ago
francissimo/grafana Fork of grafana/grafana
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.- v0.0.0-20180818164646-67afb5ed74ec go.mod
- v0.0.0-20180818164646-67afb5ed74ec go.sum
Size: 423 MB - Last synced: about 1 year ago - Pushed: about 1 year ago
qjebbs/miniflux Fork of miniflux/v2
Minimalist feed reader written in Go- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 33.6 MB - Last synced: 16 days ago - Pushed: 16 days ago
baetyl/baetyl-cloud
Remote management system of Baetyl instances- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 22 MB - Last synced: 6 days ago - Pushed: 6 days ago
stolostron/grafana Fork of grafana/grafana
The tool for beautiful monitoring and metric analytics & dashboards for Graphite, InfluxDB & Prometheus & More- v0.0.0-20180818164646-67afb5ed74ec go.mod
- v0.0.0-20180818164646-67afb5ed74ec go.sum
Size: 746 MB - Last synced: 3 days ago - Pushed: 3 days ago
lukso-network/network-explorer-consensus Fork of gobitfly/eth2-beaconchain-explorer
Open source golang based explorer for the eth2 beacon chain- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 32.2 MB - Last synced: 3 days ago - Pushed: 3 days ago
Inphi/prysm Fork of prysmaticlabs/prysm
Go implementation of Ethereum proof of stake- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 179 MB - Last synced: 26 days ago - Pushed: over 1 year ago
puppetlabs/relay 📦
Event-driven workflows for DevOps automation- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 12 MB - Last synced: 26 days ago - Pushed: about 1 year ago
sysdiglabs/redis_exporter Fork of oliver006/redis_exporter
Prometheus Exporter for Redis Metrics. Supports Redis 2.x, 3.x, 4.x, 5.x and 6.x- v0.0.0-20180818164646-67afb5ed74ec contrib/redis-mixin/go.sum
- v0.0.0-20201112154412-8562bdadbbac contrib/redis-mixin/go.sum
Size: 7.08 MB - Last synced: 4 months ago - Pushed: 4 months ago
rendicott/uggly-client
client that uses uggly grpc library- v0.0.0-20201112154412-8562bdadbbac boxes/go.mod
- v0.0.0-20201112154412-8562bdadbbac go.mod
Size: 39.1 MB - Last synced: 3 days ago - Pushed: 3 days ago
open-integration/oi
Compile your pipeline once, run anywhere- v0.0.0-20180818164646-67afb5ed74ec go.mod
- v0.0.0-20180818164646-67afb5ed74ec go.sum
Size: 1.64 MB - Last synced: 10 months ago - Pushed: about 1 year ago
gifhuppp/sourcegraph Fork of sourcegraph/sourcegraph
Universal code search (self-hosted)- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20170622235902-74a0988b5f80 go.sum
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 639 MB - Last synced: about 1 year ago - Pushed: about 1 year ago
txchat/im
高可用、高性能 IM 消息网关- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 31.3 MB - Last synced: 5 months ago - Pushed: 5 months ago
rmkraus/goreadme-all Fork of posener/goreadme
Generate readme file from Go doc, but include private resources.- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 190 KB - Last synced: about 2 months ago - Pushed: over 1 year ago
openrelayxyz/log-flume
- v0.0.0-20201112154412-8562bdadbbac flumeserver/go.sum
Size: 9.93 MB - Last synced: about 1 year ago - Pushed: over 1 year ago
openrelayxyz/cardinal-evm
- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 151 MB - Last synced: 18 days ago - Pushed: 18 days ago
datumtechs/datum-network-carrier
调度服务代码库- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 17.7 MB - Last synced: about 1 month ago - Pushed: over 1 year ago
ercole-io/ercole
Proactive Software Asset Management. Backend component- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 33.2 MB - Last synced: 30 days ago - Pushed: 30 days ago
LATOKEN/relayer-smart-contract
- v0.0.0-20170622235902-74a0988b5f80 src/go.sum
Size: 8.52 MB - Last synced: 4 months ago - Pushed: over 1 year ago
wiselike/leanote-of-unofficial
Leanote of non-official nolicensed version- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20200109203555-b30bc20e4fd1 go.sum
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 45.6 MB - Last synced: 7 days ago - Pushed: 8 days ago
remp2020/remp
REMP - Reader's engagement and monetization platform. Set of open-source tools for publishers to engage with their audience. Repository is public mirror of our internal private repo.- v0.0.0-20200109203555-b30bc20e4fd1 Beam/go/go.mod
- v0.0.0-20200109203555-b30bc20e4fd1 Beam/go/go.sum
Size: 129 MB - Last synced: 30 days ago - Pushed: 30 days ago
muir/nchi
golang http router with elegance, speed, and flexibility- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 144 KB - Last synced: 9 days ago - Pushed: 7 months ago
muir/nape
dependency injection of endpoint handlers using gorilla/mux- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 65.4 KB - Last synced: 10 months ago - Pushed: 12 months ago
reearth/reearth-backend 📦
Re:Earth back-end- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 3.08 MB - Last synced: 3 months ago - Pushed: over 1 year ago
netsec-ethz/bootstrapper
- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 270 KB - Last synced: 6 months ago - Pushed: 7 months ago
codefresh-io/pikolo
Codefresh template engine to render plugins during runtime- v0.0.0-20180818164646-67afb5ed74ec go.mod
- v0.0.0-20180818164646-67afb5ed74ec go.sum
Size: 139 KB - Last synced: 29 days ago - Pushed: about 2 months ago
fclairamb/ftpserverlib
golang ftp server library- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 4.56 MB - Last synced: 3 days ago - Pushed: 3 days ago
omegaup/prod
Deployment manifests for omegaUp- v0.0.0-20201112154412-8562bdadbbac docker/grader/fake/go.mod
- v0.0.0-20201112154412-8562bdadbbac docker/grader/fake/go.sum
Size: 1.2 MB - Last synced: 1 day ago - Pushed: 1 day ago
wtsi-ssg/wrstat
A more reliable and efficient replacement for mpistat using wr.- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20180818164646-67afb5ed74ec go.sum
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 864 KB - Last synced: 9 days ago - Pushed: about 1 month ago
codeready-toolchain/registration-service
Service for new user registration flows.- v0.0.0-20200109203555-b30bc20e4fd1 go.mod
- v0.0.0-20200109203555-b30bc20e4fd1 go.sum
Size: 1.35 MB - Last synced: 2 days ago - Pushed: 2 days ago
fluxcd/flux 📦
Successor: https://github.com/fluxcd/flux2- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 11.6 MB - Last synced: 23 days ago - Pushed: over 1 year ago
simpleiot/simpleiot
Simple IoT cloud/edge application/framework- v0.0.0-20200109203555-b30bc20e4fd1 go.mod
- v0.0.0-20200109203555-b30bc20e4fd1 go.sum
Size: 14.9 MB - Last synced: about 7 hours ago - Pushed: 1 day ago
rocket-pool/smartnode
The CLI package for Rocket Pool smart nodes.- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 18.1 MB - Last synced: 29 days ago - Pushed: 29 days ago
podhmo/individual-sandbox
indivisual sandbox- v0.0.0-20200109203555-b30bc20e4fd1 daily/20201105/example_reflectopenapi/go.mod
- v0.0.0-20180818164646-67afb5ed74ec daily/20201105/example_reflectopenapi/go.sum
- v0.0.0-20200109203555-b30bc20e4fd1 daily/20201105/example_reflectopenapi/go.sum
- v0.0.0-20201112154412-8562bdadbbac daily/20201226/example_go/go.mod
- v0.0.0-20201112154412-8562bdadbbac daily/20201226/example_go/go.sum
Size: 27.7 MB - Last synced: 6 months ago - Pushed: 6 months ago
fclairamb/ftpserver
Golang based autonomous FTP server with SFTP, S3, Dropbox, and Google Drive connectors.- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 5.39 MB - Last synced: about 10 hours ago - Pushed: 1 day ago
gearboxworks/launch
Running in Docker made trivial- v0.0.0-20200109203555-b30bc20e4fd1 go.sum
Size: 124 MB - Last synced: 21 days ago - Pushed: almost 3 years ago
lukso-network/lukso-orchestrator
Orchestrating the dance of vanguard and pandora.- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 2.13 MB - Last synced: 10 months ago - Pushed: over 2 years ago
whyrusleeping/hellabot
A hella awesome irc bot framework written in go, Simply plug in your triggers and run!- v0.0.0-20200109203555-b30bc20e4fd1 examples/commands/go.sum
- v0.0.0-20200109203555-b30bc20e4fd1 go.mod
- v0.0.0-20200109203555-b30bc20e4fd1 go.sum
Size: 127 KB - Last synced: 26 days ago - Pushed: about 1 year ago
loafoe/terraform-backend-hsdp
Store Terraform state on HSDP- v0.0.0-20180818164646-67afb5ed74ec go.sum
Size: 493 KB - Last synced: 9 months ago - Pushed: 9 months ago
openshift/osdctl
CLI for the OSD utilities- v0.0.0-20180818164646-67afb5ed74ec go.sum
Size: 25.4 MB - Last synced: 4 days ago - Pushed: 4 days ago
patrickbreen/k8s-tasks
- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 29.6 MB - Last synced: about 1 year ago - Pushed: almost 2 years ago
masterzen/winrm
Command-line tool and library for Windows remote command execution in Go- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 247 KB - Last synced: 11 days ago - Pushed: 22 days ago
logzio/logzio-metrics-ui
- v0.0.0-20180818164646-67afb5ed74ec go.mod
- v0.0.0-20180818164646-67afb5ed74ec go.sum
Size: 14.2 MB - Last synced: about 1 year ago - Pushed: about 1 year ago
uhthomas/sourcegraph Fork of sourcegraph/sourcegraph
Universal code search (self-hosted)- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20170622235902-74a0988b5f80 go.sum
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 812 MB - Last synced: 10 months ago - Pushed: 11 months ago
BuildOnViction/proxy
Light-weight TomoChain RPC proxy- 67afb5ed74ec82fd7ac8f49d27c509ac6f991970 Gopkg.lock
- v0.0.0-20180818164646-67afb5ed74ec go.mod
- v0.0.0-20180818164646-67afb5ed74ec go.sum
Size: 1.22 MB - Last synced: 24 days ago - Pushed: over 2 years ago
baetyl/baetyl-go
Golang SDK for BAETYL V2- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 939 KB - Last synced: 11 days ago - Pushed: 5 months ago
txchat/dtalk
IM业务服务- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 22.7 MB - Last synced: 10 months ago - Pushed: 11 months ago
fclairamb/go-log
- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 78.1 KB - Last synced: about 16 hours ago - Pushed: about 17 hours ago
baetyl/baetyl-adapter
All modules that synchronize data with the clients, such as mqtt, modbus, coap, etc.- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 9.16 MB - Last synced: 11 days ago - Pushed: 10 months ago
softree-group/protocall
Сервис для создания онлайн конференций с возможностью трансляции речи участников в текст- v0.0.0-20171019012758-0decfc6c20d9 go.mod
- v0.0.0-20171019012758-0decfc6c20d9 go.sum
Size: 1.13 MB - Last synced: about 1 year ago - Pushed: over 2 years ago
shaj13/go-guardian
Go-Guardian is a golang library that provides a simple, clean, and idiomatic way to create powerful modern API and web authentication.- v0.0.0-20170622235902-74a0988b5f80 go.sum
Size: 345 KB - Last synced: 11 days ago - Pushed: 4 months ago
Stolarskis/goPlant
- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 4.24 MB - Last synced: 9 months ago - Pushed: over 2 years ago
omegaup/gitserver
The omegaUp git server for problems- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 486 KB - Last synced: about 2 months ago - Pushed: about 1 year ago
omegaup/githttp
A Go implementation of Git's HTTP "smart" protocol.- v0.0.0-20201112154412-8562bdadbbac go.mod
- v0.0.0-20201112154412-8562bdadbbac go.sum
Size: 205 KB - Last synced: about 2 months ago - Pushed: over 1 year ago