logger

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestParamError = "请求参数错误"
	FileNotFoundError = "Log文件不存在"
	InnerServerError  = "服务器内部错误"
)

错误消息

View Source
const LogTypeError = 1

LogTypeError 错误类型

View Source
const LogTypeInfo = 0

LogTypeInfo 信息类型

View Source
const LogTypeSuccess = 2

LogTypeSuccess 成功类型

Variables

View Source
var Logger = logrus.New().WithField("name", "haruno")

Logger 应用使用的 logger 实例

View Source
var Service loggerService

Service 单例实体

Functions

func Error added in v0.0.8

func Error(text string)

Error 错误log

func Errorf added in v0.0.8

func Errorf(format string, args ...interface{})

Errorf 格式化错误log

func Info added in v0.0.8

func Info(text string)

Info 信息log

func Infof added in v0.0.8

func Infof(format string, args ...interface{})

Infof 格式化信息log

func RawLogHandler

func RawLogHandler(w http.ResponseWriter, r *http.Request)

RawLogHandler 获取log文件

func Success added in v0.0.8

func Success(text string)

Success 成功log

func Successf added in v0.0.8

func Successf(format string, args ...interface{})

Successf 格式化成功log

func WSLogHandler

func WSLogHandler(w http.ResponseWriter, r *http.Request)

WSLogHandler 广播log

Types

type Log

type Log struct {
	Time int64  `json:"time"`
	Type int    `json:"type"`
	Text string `json:"text"`
}

Log log消息格式(json)

func NewLog

func NewLog(ltype int, text string) *Log

NewLog 创建一个新的Log实例

type LogInterface added in v0.0.8

type LogInterface interface {
	Success(string)
	Successf(string, ...interface{})
	Info(string)
	Infof(string, ...interface{})
	Error(string)
	Errorf(string, ...interface{})
}

LogInterface 基础的logger接口

func Field added in v0.0.8

func Field(name string) LogInterface

Field 设置logger的域

Jump to

Keyboard shortcuts

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