logger
json(default), txt.
log level :
debug, info, warn, error
above values can be set using environment variable :
LOGGING_LEVEL & LOGGING_FORMAT
Log with traceable context
// Either create a span from existing request context or create a fresh one
package example
import (
"context"
"logger/logging"
"github.com/opentracing/opentracing-go"
)
var log logging.Logger
func myOperation(parentCtx context.Context) {
span, ctx := opentracing.StartSpanFromContext(parentCtx, "myOperation")
defer span.Finish()
log.Info(ctx, "Message")
}
####output :
{"is_sampled":"false","level":"info","logger":"logging_test.go:70","message":"Message","parent_id":"0","span_id":"54b168451e541edd","timestamp":"2020-12-11T12:02:00.370+02:00","trace_id":"54b168451e541edd"}
####Example execution
Ref :
- https://opentracing.io/guides/golang/quick-start/
- https://github.com/jaegertracing/jaeger-client-go
- https://www.sentinelone.com/blog/jaeger-tracing-tutorial/