Documentation
¶
Index ¶
- Variables
- func Carriers(ctx context.Context, op ...string) opentracing.TextMapCarrier
- func Close()
- func ContextByCarrier(carrier opentracing.TextMapCarrier, operationName string, tag ...string) (ctx context.Context)
- func CtxLog(ctx context.Context) *logrus.Entry
- func Elapsed(st time.Time, l ...*logrus.Entry) *logrus.Entry
- func Err(err error, l ...*logrus.Entry) *logrus.Entry
- func GetServiceName() string
- func InitFromConfig(c *Config) (err error)
- func InitFromEnv() (err error)
- func InitOnlyTracingLog(serviceName string) error
- func Logger() *logrus.Logger
- func RequestID(ctx context.Context) string
- func StartContext(ctx context.Context, operationName string) context.Context
- func Std() *logrus.Logger
- func TraceID(ctx context.Context) string
- type Config
- type JSONLoggerFormatter
- type MDReaderWriter
- type TextLoggerFormatter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( SetFormatter = xLOG.SetFormatter SetOutput = xLOG.SetOutput SetLevel = xLOG.SetLevel SetReportCaller = xLOG.SetReportCaller Info = xLOG.Info Infof = xLOG.Infof Error = xLOG.Error Errorf = xLOG.Errorf Trace = xLOG.Trace Tracef = xLOG.Tracef WithFields = xLOG.WithFields )
Functions ¶
func ContextByCarrier ¶
func GetServiceName ¶
func GetServiceName() string
func InitOnlyTracingLog ¶
只生成链式日志,无需jaeger服务,不采样,不上报
Types ¶
type Config ¶
type Config struct { ServiceName string `json:"ServiceName" yaml:"ServiceName"` //服务名, 必须 JaegerAgent string `json:"JaegerAgent" yaml:"JaegerAgent"` //jaeger-agent地址,可选: 默认:jaeger-agent:6831 SamplerRateLimit float64 `json:"SamplerRateLimit" yaml:"SamplerRateLimit"` //<=0 永不上报,< 1 按固定概率上报,> 1 限制每秒最大上报数量,=1 总是上报 QueueSize int `json:"QueueSize" yaml:"QueueSize"` //异步span队列最大大小,可选:默认100 BufferFlushInterval int `json:"BufferFlushInterval" yaml:"BufferFlushInterval"` //buff刷新间隔,可选:默认1 单位:秒 }
Config 配置文件
type JSONLoggerFormatter ¶
type JSONLoggerFormatter struct { }
func (JSONLoggerFormatter) Format ¶
func (formatter JSONLoggerFormatter) Format(entry *logrus.Entry) ([]byte, error)
FormatDefault = "[${serviceName},${traceID},${spanID},${parentSpanID}][${pid}]"
timestamp := entry.Time.Format("2006-01-02 15:04:05")
return []byte(fmt.Sprintf("%s %s %s\n", timestamp, strings.ToUpper(entry.Level.String()), entry.Message)), nil
type MDReaderWriter ¶
func (MDReaderWriter) ForeachKey ¶
func (c MDReaderWriter) ForeachKey(handler func(key, val string) error) error
func (MDReaderWriter) Set ¶
func (c MDReaderWriter) Set(key, val string)
type TextLoggerFormatter ¶
type TextLoggerFormatter struct { }
func (TextLoggerFormatter) Format ¶
func (formatter TextLoggerFormatter) Format(entry *logrus.Entry) ([]byte, error)
FormatDefault = "[${serviceName},${traceID},${spanID},${parentSpanID}][${pid}]"
timestamp := entry.Time.Format("2006-01-02 15:04:05")
return []byte(fmt.Sprintf("%s %s %s\n", timestamp, strings.ToUpper(entry.Level.String()), entry.Message)), nil
Click to show internal directories.
Click to hide internal directories.