logger

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TraceIDKey 跟踪ID
	TraceIDKey = "trace_id"
	// SpanIDKey 请求ID
	SpanIDKey = "span_id"
	// UserIDKey 用户ID
	UserIDKey = "user_id"
)

Variables

This section is empty.

Functions

func DefaultFormatter

func DefaultFormatter(fields logrus.Fields) logrus.Formatter

DefaultFormatter returns a default Logstash formatter: A JSON format with "@version" set to "1" (unless set differently in `fields`, "type" to "log" (unless set differently in `fields`), "@timestamp" to the log time and "message" to the log message.

Note: to set a different configuration use the `LogstashFormatter` structure.

func NewRedisHook

func NewRedisHook(redis *redis.Client, fields logrus.Fields, channel string) logrus.Hook

NewRedisHook ...

func WithGinContext

func WithGinContext(ctx *gin.Context) context.Context

WithGinContext ...

Types

type LogstashFormatter

type LogstashFormatter struct {
	logrus.Formatter
	logrus.Fields
}

LogstashFormatter represents a Logstash format. It has logrus.Formatter which formats the entry and logrus.Fields which are added to the JSON message if not given in the entry data.

Note: use the `DefaultFormatter` function to set a default Logstash formatter.

func (*LogstashFormatter) Format

func (f *LogstashFormatter) Format(e *logrus.Entry) ([]byte, error)

Format formats an entry to a Logstash format according to the given Formatter and Fields.

Note: the given entry is copied and not changed during the formatting process.

type RedisHook

type RedisHook struct {
	Channel string

	LogLevels []logrus.Level
	// contains filtered or unexported fields
}

RedisHook ...

func (*RedisHook) Fire

func (h *RedisHook) Fire(e *logrus.Entry) error

Fire ...

func (*RedisHook) Levels

func (h *RedisHook) Levels() []logrus.Level

Levels returns all logrus levels.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL