Documentation ¶
Overview ¶
Package logrus is a plugin that can be transmit trace context to the log framework.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WrapFormat ¶
WrapFormat is wrap format to transmit trace context when logging
Example ¶
context := context.Background() logrus.SetOutput(os.Stdout) // init tracer _, err := go2sky.NewTracer("example") if err != nil { logrus.Fatalf("create tracer error %v \n", err) } // json format logrus.SetFormatter(Wrap(&logrus.JSONFormatter{ DisableTimestamp: true, }, "SW_CTX")) logrus.WithContext(context).Info("test1") // test format logrus.SetFormatter(Wrap(&logrus.TextFormatter{ DisableTimestamp: true, }, "SW_CTX")) logrus.WithContext(context).Info("test2")
Output: {"SW_CTX":"[,,N/A,N/A,-1]","level":"info","msg":"test1"} level=info msg=test2 SW_CTX="[,,N/A,N/A,-1]"
Click to show internal directories.
Click to hide internal directories.