status-go/vendor/github.com/ipfs/go-log
RichΛrd 40359f9c1b
go-waku integration (#2247)
* Adding wakunode module
* Adding wakuv2 fleet files
* Add waku fleets to update-fleet-config script
* Adding config items for waku v2
* Conditionally start waku v2 node depending on config
* Adapting common code to use go-waku
* Setting log level to info
* update dependencies
* update fleet config to use WakuNodes instead of BootNodes
* send and receive messages
* use hash returned when publishing a message
* add waku store protocol
* trigger signal after receiving store messages
* exclude linting rule SA1019 to check deprecated packages
2021-06-16 16:19:45 -04:00
..
tracer go-waku integration (#2247) 2021-06-16 16:19:45 -04:00
v2 go-waku integration (#2247) 2021-06-16 16:19:45 -04:00
writer go-waku integration (#2247) 2021-06-16 16:19:45 -04:00
.travis.yml go-waku integration (#2247) 2021-06-16 16:19:45 -04:00
LICENSE Add rendezvous implementation for discovery interface 2018-07-25 15:10:57 +03:00
README.md go-waku integration (#2247) 2021-06-16 16:19:45 -04:00
context.go Add rendezvous implementation for discovery interface 2018-07-25 15:10:57 +03:00
entry.go Add rendezvous implementation for discovery interface 2018-07-25 15:10:57 +03:00
go.mod go-waku integration (#2247) 2021-06-16 16:19:45 -04:00
go.sum go-waku integration (#2247) 2021-06-16 16:19:45 -04:00
levels.go go-waku integration (#2247) 2021-06-16 16:19:45 -04:00
log.go go-waku integration (#2247) 2021-06-16 16:19:45 -04:00
loggable.go Add rendezvous implementation for discovery interface 2018-07-25 15:10:57 +03:00
metadata.go Add rendezvous implementation for discovery interface 2018-07-25 15:10:57 +03:00
oldlog.go go-waku integration (#2247) 2021-06-16 16:19:45 -04:00
package.json migrate to go 1.12 and go modules 2019-06-12 13:12:00 +02:00

README.md

go-log

standard-readme compliant GoDoc Build Status

The logging library used by go-ipfs

It currently uses a modified version of go-logging to implement the standard printf-style log output.

Install

go get github.com/ipfs/go-log

Usage

Once the package is imported under the name logging, an instance of EventLogger can be created like so:

var log = logging.Logger("subsystem name")

It can then be used to emit log messages, either plain printf-style messages at six standard levels or structured messages using Start, StartFromParentState, Finish and FinishWithErr methods.

Example

func (s *Session) GetBlock(ctx context.Context, c *cid.Cid) (blk blocks.Block, err error) {

    // Starts Span called "Session.GetBlock", associates with `ctx`
    ctx = log.Start(ctx, "Session.GetBlock")

    // defer so `blk` and `err` can be evaluated after call
    defer func() {
        // tag span associated with `ctx`
        log.SetTags(ctx, map[string]interface{}{
            "cid": c,
            "block", blk,
        })
        // if err is non-nil tag the span with an error
        log.FinishWithErr(ctx, err)
    }()

    if shouldStartSomething() {
        // log message on span associated with `ctx`
        log.LogKV(ctx, "startSomething", true)
    }
  ...
}

Tracing

go-log wraps the opentracing-go methods - StartSpan, Finish, LogKV, and SetTag.

go-log implements its own tracer - loggabletracer - based on the basictracer-go implementation. If there is an active WriterGroup the loggabletracer will record span data to the WriterGroup. An example of this can be seen in the log tail command of go-ipfs.

Third party tracers may be used by calling opentracing.SetGlobalTracer() with your desired tracing implementation. An example of this can be seen using the go-jaeger-plugin and the go-ipfs tracer plugin

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

Want to hack on IPFS?

License

MIT