Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ipfs/go-log
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.0.0
Choose a base ref
...
head repository: ipfs/go-log
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.0.1
Choose a head ref
  • 3 commits
  • 33 files changed
  • 2 contributors

Commits on Nov 21, 2019

  1. remove deprecated code and update README

    frrist authored and lanzafame committed Nov 21, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    lanzafame Adrian Lanzafame
    Copy the full SHA
    eede8da View commit details
  2. Merge pull request #65 from ipfs/frrist/remove-deprecated

    remove deprecated code and update README
    lanzafame authored Nov 21, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9152120 View commit details
  3. fix go.mod

    lanzafame committed Nov 21, 2019
    Copy the full SHA
    69423ed View commit details
Showing with 18 additions and 3,444 deletions.
  1. +17 −30 README.md
  2. +0 −38 context.go
  3. +0 −43 context_test.go
  4. +0 −7 entry.go
  5. +0 −16 example_test.go
  6. +1 −1 go.mod
  7. +0 −375 log.go
  8. +0 −449 log_test.go
  9. +0 −42 loggable.go
  10. +0 −77 metadata.go
  11. +0 −50 metadata_test.go
  12. +0 −20 oldlog.go → setup.go
  13. +0 −21 tracer/LICENSE
  14. +0 −42 tracer/context.go
  15. +0 −78 tracer/debug.go
  16. +0 −62 tracer/event.go
  17. +0 −61 tracer/propagation.go
  18. +0 −180 tracer/propagation_ot.go
  19. +0 −34 tracer/raw.go
  20. +0 −103 tracer/recorder.go
  21. +0 −54 tracer/recorder_test.go
  22. +0 −274 tracer/span.go
  23. +0 −280 tracer/tracer.go
  24. +0 −25 tracer/util.go
  25. +0 −6 tracer/wire/Makefile
  26. +0 −40 tracer/wire/carrier.go
  27. +0 −38 tracer/wire/carrier_test.go
  28. +0 −6 tracer/wire/gen.go
  29. +0 −554 tracer/wire/wire.pb.go
  30. +0 −10 tracer/wire/wire.proto
  31. +0 −4 writer/option.go
  32. +0 −258 writer/writer.go
  33. +0 −166 writer/writer_test.go
47 changes: 17 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -12,7 +12,8 @@

> The logging library used by go-ipfs
It currently uses a modified version of [go-logging](https://github.com/whyrusleeping/go-logging) to implement the standard printf-style log output.
go-log wraps [zap](https://github.com/uber-go/zap) to provide a logging facade. go-log manages logging
instances and allows for their levels to be controlled individually.

## Install

@@ -28,41 +29,27 @@ Once the package is imported under the name `logging`, an instance of `EventLogg
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.
It can then be used to emit log messages in plain printf-style messages at seven standard levels:

## Example
Levels may be set for all loggers:

```go
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)
}
...
}
lvl, err := logging.LevelFromString("error")
if err != nil {
panic(err)
}
logging.SetAllLoggers(lvl)
```
## Tracing

`go-log` wraps the [opentracing-go](https://github.com/opentracing/opentracing-go) methods - `StartSpan`, `Finish`, `LogKV`, and `SetTag`.
or individually:

`go-log` implements its own tracer - `loggabletracer` - based on the [basictracer-go](https://github.com/opentracing/basictracer-go) implementation. If there is an active [`WriterGroup`](https://github.com/ipfs/go-log/blob/master/writer/option.go) the `loggabletracer` will [record](https://github.com/ipfs/go-log/blob/master/tracer/recorder.go) span data to the `WriterGroup`. An example of this can be seen in the [`log tail`](https://github.com/ipfs/go-ipfs/blob/master/core/commands/log.go) 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`](https://github.com/ipfs/go-jaeger-plugin) and the `go-ipfs` [tracer plugin](https://github.com/ipfs/go-ipfs/blob/master/plugin/tracer.go)
```go
lvl, err := logging.LevelFromString("error")
if err != nil {
panic(err)
}
logging.SetLogLevel("foo", "info")
```

## Contribute

38 changes: 0 additions & 38 deletions context.go

This file was deleted.

43 changes: 0 additions & 43 deletions context_test.go

This file was deleted.

7 changes: 0 additions & 7 deletions entry.go

This file was deleted.

16 changes: 0 additions & 16 deletions example_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/ipfs/go-log
module github.com/ipfs/go-log/v2

require (
github.com/gogo/protobuf v1.2.1
Loading