logger

package
v0.0.0-...-58dc058 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 5 Imported by: 0

README

日志

  • import
import "github.com/fideism/golang-tools/logger"
  • use

不设置 channel

logger.NewEntry().WithFields(logrus.Fields{
		"kwy": "value",
	}).Info("message")

设置 channel

logger.NewEntry(logger.Channel("sms")).Info("设置channel为 sms")

统一设置

logger.SetOption(logger.Channel("sms"))

logger.Entry().Info("channel sms")
  • channle 使用 logger.Channel("sms") 指定特定的channel,方便日志收集

Documentation

Index

Constants

View Source
const DefaultTimestampFormat = `2006-01-02 15:04:05`

DefaultTimestampFormat 默认日期解析格式

Variables

Log 实例

Functions

func SetOption

func SetOption(option ...LogstashFormatterOption)

SetOption 设置参数

Types

type Logger

type Logger struct {
	*logrus.Entry
}

Logger 实例

func Entry

func Entry() *Logger

Entry 返回默认日志

func NewEntry

func NewEntry(option ...LogstashFormatterOption) *Logger

NewEntry 返回默认日志

func (*Logger) WithError

func (entry *Logger) WithError(err error) *logrus.Entry

WithError 重载error

type LogstashFormatter

type LogstashFormatter struct {
	Channel string
}

LogstashFormatter 日志格式化

func (*LogstashFormatter) Format

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

Format 格式化

type LogstashFormatterOption

type LogstashFormatterOption func(*LogstashFormatter)

LogstashFormatterOption 日志格式化参数

func Channel

Channel 动态修改channel 默认为空

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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