Documentation ¶
Overview ¶
Package zap is a plugin that can be transmit trace context to the log framework.
Index ¶
- Constants
- func TraceContext(ctx context.Context) []zap.Field
- type WrapLogger
- func (log *WrapLogger) Check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry
- func (log *WrapLogger) Core() zapcore.Core
- func (log *WrapLogger) DPanic(ctx context.Context, msg string, fields ...zap.Field)
- func (log *WrapLogger) Debug(ctx context.Context, msg string, fields ...zap.Field)
- func (log *WrapLogger) Error(ctx context.Context, msg string, fields ...zap.Field)
- func (log *WrapLogger) Fatal(ctx context.Context, msg string, fields ...zap.Field)
- func (log *WrapLogger) Info(ctx context.Context, msg string, fields ...zap.Field)
- func (log *WrapLogger) Named(s string) *WrapLogger
- func (log *WrapLogger) Panic(ctx context.Context, msg string, fields ...zap.Field)
- func (log *WrapLogger) Sync() error
- func (log *WrapLogger) Warn(ctx context.Context, msg string, fields ...zap.Field)
- func (log *WrapLogger) With(fields ...zap.Field) *WrapLogger
- func (log *WrapLogger) WithOptions(opts ...zap.Option) *WrapLogger
Examples ¶
Constants ¶
View Source
const HeaderKeyCtx = "SW_CTX"
HeaderKeyCtx export zap field key name
Variables ¶
This section is empty.
Functions ¶
func TraceContext ¶
TraceContext build all SkyWalking Trace Context to zap fields
Example ¶
package main import ( "context" zapplugin "github.com/SkyAPM/go2sky-plugins/zap" "go.uber.org/zap" ) func main() { ctx := context.Background() logger := zap.NewExample() logger.With(zapplugin.TraceContext(ctx)...).Info("test") }
Output: {"level":"info","msg":"test","SW_CTX":"[,,N/A,N/A,-1]"}
Types ¶
type WrapLogger ¶
type WrapLogger struct {
// contains filtered or unexported fields
}
WrapLogger is wrap the zap logger, also contains all method at zap logger, correlate the context before logging
func WrapWithContext ¶
func WrapWithContext(logger *zap.Logger) *WrapLogger
WrapWithContext original zap logger(not sugar)
Example ¶
package main import ( "context" zapplugin "github.com/SkyAPM/go2sky-plugins/zap" "go.uber.org/zap" ) func main() { ctx := context.Background() logger := zapplugin.WrapWithContext(zap.NewExample()) logger.Info(ctx, "test") }
Output: {"level":"info","msg":"test","SW_CTX":"[,,N/A,N/A,-1]"}
func (*WrapLogger) Check ¶
func (log *WrapLogger) Check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry
Check wrap the zap logging function
func (*WrapLogger) Core ¶
func (log *WrapLogger) Core() zapcore.Core
Core wrap the zap logging function
func (*WrapLogger) Named ¶
func (log *WrapLogger) Named(s string) *WrapLogger
Named wrap the zap logging function
func (*WrapLogger) With ¶
func (log *WrapLogger) With(fields ...zap.Field) *WrapLogger
With wrap the zap logging function
func (*WrapLogger) WithOptions ¶
func (log *WrapLogger) WithOptions(opts ...zap.Option) *WrapLogger
WithOptions wrap the zap logging function
Click to show internal directories.
Click to hide internal directories.