base

package
v0.0.0-...-63bff7e Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2018 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TIMESTAMP_FORMAT 代表时间戳格式化字符串。
	TIMESTAMP_FORMAT = "2006-01-02T15:04:05.999"
)

Variables

This section is empty.

Functions

func GetInvokerLocation

func GetInvokerLocation(skipNumber int) (funcPath string, fileName string, line int)

GetInvokerLocation 用于获得调用位置。

Types

type LogFormat

type LogFormat string

LogFormat 表示日志格式的类型。

const (
	// FORMAT_TEXT 代表普通文本的日志格式。
	FORMAT_TEXT LogFormat = "text"
	// FORMAT_JSON 代表JSON的日志格式。
	FORMAT_JSON LogFormat = "json"
)

type LogLevel

type LogLevel uint8

LoggerLevel 代表日志输出级别。

const (
	// LEVEL_DEBUG 代表调试级别,是最低的日志等级。
	LEVEL_DEBUG LogLevel = iota + 1
	// LEVEL_INFO 代表信息级别,是最常用的日志等级。
	LEVEL_INFO
	// LEVEL_WARN 代表警告级别,是适合输出到错误输出的日志等级。
	LEVEL_WARN
	// LEVEL_ERROR 代表普通错误级别,是建议输出到错误输出的日志等级。
	LEVEL_ERROR
	// LEVEL_FATAL 代表致命错误级别,是建议输出到错误输出的日志等级。
	// 此级别的日志一旦输出就意味着`os.Exit(1)`立即会被调用。
	LEVEL_FATAL
	// LEVEL_PANIC 代表恐慌级别,是最高的日志等级。
	// 此级别的日志一旦输出就意味着运行时恐慌立即会被引发。
	LEVEL_PANIC
)

type LoggerType

type LoggerType string

LoggerType 代表日志记录器类型。

const (
	// TYPE_LOGRUS 代表基于logrus的日志记录器类型。
	TYPE_LOGRUS LoggerType = "logrus"
)

type MyLogger

type MyLogger interface {
	Name() string
	Level() LogLevel
	Format() LogFormat
	Options() []Option

	Debug(v ...interface{})
	Debugf(format string, v ...interface{})
	Debugln(v ...interface{})
	Error(v ...interface{})
	Errorf(format string, v ...interface{})
	Errorln(v ...interface{})
	Fatal(v ...interface{})
	Fatalf(format string, v ...interface{})
	Fatalln(v ...interface{})
	Info(v ...interface{})
	Infof(format string, v ...interface{})
	Infoln(v ...interface{})
	Panic(v ...interface{})
	Panicf(format string, v ...interface{})
	Panicln(v ...interface{})
	Warn(v ...interface{})
	Warnf(format string, v ...interface{})
	Warnln(v ...interface{})

	// WithFields 会增加需记录的额外字段。
	WithFields(fields ...field.Field) MyLogger
}

MyLogger 代表日志记录器的接口。

type OptWithLocation

type OptWithLocation struct {
	Value bool
}

OptWithLocation 代表一个日志记录器选项的类型。 该选项的值是bool类型的, 代表表示记录日志时是否带有调用方的代码位置。

func (OptWithLocation) Name

func (opt OptWithLocation) Name() string

type Option

type Option interface {
	Name() string
}

Option 代表日志记录器的选项。

Jump to

Keyboard shortcuts

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