Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AppVersion = ""
AppVersion is exposed to allow build time versions to be set. go build -ldflags="-X 'github.com/joerdav/zapray.AppVersion.AppVersion=v1.0.0'"
Functions ¶
Types ¶
type Logger ¶
Logger is a wrapper for zap.Logger, exposes the zap.Logger functions and adds the ability to Trace logs.
func NewDevelopment ¶
NewDevelopment creates a new instance of *Logger and includes a zap.NewDevelopment().
log := zapray.NewDevelopment()
func NewLogger ¶
NewLogger creates a new instance of *Logger and wraps the logger provided.
z, _ := zap.NewProduction() log := zapray.NewLogger(z)
func NewNop ¶
func NewNop() *Logger
NewNop creates a new instance of *Logger and includes a zap.NewNop().
log := zapray.NewNop()
func NewProduction ¶
NewProduction creates a new instance of *Logger and includes a zap.NewProduction().
log := zapray.NewProduction()
func (*Logger) Named ¶
Named delegates to zap.Logger.Named and wraps the resulting logger into a zapray.Logger
func (*Logger) Trace ¶
Trace creates a new zap.Logger but with the xrayTraceId and xraySegmentId baked in.
log.Trace(ctx).Info("myLog")
Once trace is called you can use it as a zap.Logger.
tracedLogger := log.Trace(ctx) tracedLogger.Info("Log one") tracedLogger.Info("Log two")
This means as above you can trace once and use the provided logger.
func (*Logger) TraceRequest ¶
TraceRequest creates a new zap.Logger but with the xrayTraceId and xraySegmentId baked in.
log.TraceRequest(r).Info("myLog")
Once trace is called you can use it as a zap.Logger.
tracedLogger := log.Trace(r) tracedLogger.Info("Log one") tracedLogger.Info("Log two")
This means as above you can trace once and use the provided logger.
type Middleware ¶
Middlware applies X-Ray segements to the wrapped handler.
func (Middleware) ServeHTTP ¶
func (h Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request)