wlog

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

README

Intrucdutions

日志组件

日志级别

  1. Info 普通级别,用户打印功能日志,方便用户排错
  2. Debug 开发阶段日志,上线不会打印。方便调试
  3. Warning 告警日志。这个级别的日志可以用来进行监控告警
  4. Error 错误日志,出现业务错误时,方便差错

v1.0.0 版本功能

  1. 满足基本的日志功能 -. 日志输出 (文件,控制台)

v1.0.1 版本

  1. 支持GA模块封装

v1.0.2 版本

  1. 支持夜莺上报

Documentation

Index

Constants

View Source
const Version = "v1.0.2"

Variables

View Source
var ErrorAdapter = errors.New("please set log adapter")

Functions

func AppID added in v1.0.3

func AppID(string)

func Date added in v1.0.3

func Date(string)

func ErrorCode added in v1.0.3

func ErrorCode(string)

func ErrorMsg added in v1.0.3

func ErrorMsg(string)

func EventID added in v1.0.3

func EventID(string)

func Host added in v1.0.3

func Host(string)

func Metadata added in v1.0.3

func Metadata(map[string]string)

func NameSpace added in v1.0.3

func NameSpace(string)

func Object added in v1.0.3

func Object(interface{})

func Package added in v1.0.3

func Package(string)

func RequestID added in v1.0.3

func RequestID(string)

func Route added in v1.0.3

func Route(string)

func ServerID added in v1.0.3

func ServerID(string)

func Timestamp added in v1.0.3

func Timestamp(int64)

func UserAgent added in v1.0.3

func UserAgent(string)

func UserID added in v1.0.3

func UserID(string)

Types

type AdapterLogger

type AdapterLogger interface {
	Info(level Level, msg string, field TYFields)
}

type Elk added in v1.0.3

type Elk struct {
	*Entry
}

type Entry

type Entry struct {
	Data   TYFields
	Logger *Log
	// contains filtered or unexported fields
}

func (*Entry) Debug

func (entry *Entry) Debug(msg string)

Debug 打印调试日志

func (*Entry) Error

func (entry *Entry) Error(msg string)

Error 打印错误日志

func (*Entry) ErrorMsg

func (elk *Entry) ErrorMsg(value string) *Entry

ErrorMsg 错误信息

func (*Entry) ErrorReport

func (elk *Entry) ErrorReport(value string) *Entry

ErrorReport 错误上报

func (*Entry) EventId

func (elk *Entry) EventId(value string) *Entry

EventId 事件id

func (*Entry) EventParam

func (elk *Entry) EventParam(params interface{}) *Entry

EventParam 时间参数

func (*Entry) Flush

func (entry *Entry) Flush() *Entry

Flush 输出日志

func (*Entry) Info

func (entry *Entry) Info(msg string)

Info 打印普通日志

func (*Entry) Int

func (entry *Entry) Int(key string, value int) *Entry

Int 类型

func (*Entry) Int32

func (entry *Entry) Int32(key string, value int32) *Entry

Int32 值类型的数据

func (*Entry) Int64

func (entry *Entry) Int64(key string, value int64) *Entry

Int64 类型

func (*Entry) Metadata added in v1.0.3

func (elk *Entry) Metadata(data map[string]string) *Entry

Metadata

func (*Entry) MustAppend

func (entry *Entry) MustAppend() *Entry

MustAppend 预定义字段

func (*Entry) MustAppendContext

func (elk *Entry) MustAppendContext(ctx context.Context) *Entry

MustAppendContext context

func (*Entry) MustAppendFromGinContext

func (elk *Entry) MustAppendFromGinContext(ctx *gin.Context) *Entry

MustAppendFromGinContext 使用gin context

func (*Entry) NameSpace added in v1.0.3

func (elk *Entry) NameSpace(value string) *Entry

NameSpace 项目ID

func (*Entry) Object

func (entry *Entry) Object(key string, value interface{}) *Entry

Object 类数据

func (*Entry) Rparam

func (elk *Entry) Rparam(params interface{}) *Entry

Rparam 时间参数

func (*Entry) String

func (entry *Entry) String(key string, value string) *Entry

String 类型

func (*Entry) SubEventId

func (elk *Entry) SubEventId(value string) *Entry

SubEventId subeventId

func (*Entry) UseID added in v1.0.3

func (elk *Entry) UseID(value string) *Entry

NameSpace 项目ID

func (*Entry) Warning

func (entry *Entry) Warning(msg string)

Warning 打印警告日志

type Level

type Level int
const (
	DEBUG Level = iota + 1
	INFO
	WARNING
	ERROR
)

type Log added in v1.0.3

type Log struct {
	// contains filtered or unexported fields
}

log tylog日志

func NewLogger added in v1.0.3

func NewLogger(adapterLogger AdapterLogger, msg string) *Log

NewLogger 创建新的日志组件

func (*Log) WithElkEntry added in v1.0.3

func (log *Log) WithElkEntry(msg string) *Entry

NewEntry creates a elk entry

func (*Log) WithEntry added in v1.0.3

func (log *Log) WithEntry(msg string) *Entry

NewEntry creates a new entry

type Logger

type Logger interface {
	Info(msg string)
	Debug(msg string)
	Warning(msg string)
	Error(msg string)
}

type TYFields

type TYFields map[string]interface{}

TYFileds type, used to pass to `WithFields`.

Directories

Path Synopsis
cmd
elk
lib
beego
Package logs provide a general log interface Usage: import "github.com/astaxie/beego/logs" log := NewLogger(10000) log.SetLogger("console", "") > the first params stand for how many channel Use it like this: log.Trace("trace") log.Info("info") log.Warn("warning") log.Debug("debug") log.Critical("critical") more docs http://beego.me/docs/module/logs.md Copyright 2014 mqant Author.
Package logs provide a general log interface Usage: import "github.com/astaxie/beego/logs" log := NewLogger(10000) log.SetLogger("console", "") > the first params stand for how many channel Use it like this: log.Trace("trace") log.Info("info") log.Warn("warning") log.Debug("debug") log.Critical("critical") more docs http://beego.me/docs/module/logs.md Copyright 2014 mqant Author.

Jump to

Keyboard shortcuts

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