https://github.com/lileio/logr
Adds Opentracing (Zipkin) to Logrus loggers
https://github.com/lileio/logr
go logging logrus opentracing
Last synced: 8 months ago
JSON representation
Adds Opentracing (Zipkin) to Logrus loggers
- Host: GitHub
- URL: https://github.com/lileio/logr
- Owner: lileio
- License: mit
- Created: 2018-04-27T14:54:22.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-25T04:12:48.000Z (almost 3 years ago)
- Last Synced: 2025-05-10T23:02:45.110Z (8 months ago)
- Topics: go, logging, logrus, opentracing
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 18
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Logr
Logr is a simple helper for [Logrus](https://github.com/sirupsen/logrus) which helps wrap loggers to log [Opentracing](http://opentracing.io/) information.
### Example
If you have a context that might already be in a trace, then you can simple create a new Logrus logger with your context. This a gRPC handler for example.
``` go
func (s *routeGuideServer) GetFeature(ctx context.Context, point *pb.Point) (*pb.Feature, error) {
logr.WithCtx(ctx).Info("Called GetFeature woo!")
}
```
### Interface
Logr follows the `logr.FieldLogger` interface
``` go
type FieldLogger interface {
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Printf(format string, args ...interface{})
Warnf(format string, args ...interface{})
Warningf(format string, args ...interface{})
Errorf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
Panicf(format string, args ...interface{})
Debug(args ...interface{})
Info(args ...interface{})
Print(args ...interface{})
Warn(args ...interface{})
Warning(args ...interface{})
Error(args ...interface{})
Fatal(args ...interface{})
Panic(args ...interface{})
}
```