Documentation ¶
Overview ¶
Package glogs is a global internal glogs glogs: this is extend package, use https://github.com/uber-go/zap
Index ¶
- Constants
- Variables
- func Default(writer *zap.Logger, level logger.LogLevel) logger.Interface
- func Error(template string, args ...interface{})
- func ErrorF(r *http.Request, title string, template string, args ...interface{})
- func GetSpanContextKey() string
- func GetWriter(filename string, lc *Config) io.Writer
- func Info(template string, args ...interface{})
- func InfoF(r *http.Request, title string, template string, args ...interface{})
- func InitDing(key, host string)
- func InitLog(options ...LogOptionFunc)
- func InitTrace(serviceName, serviceEndpoint, zipkinAddr string, mod uint64) error
- func Inject(ctx context.Context, r *http.Request) error
- func SendDing(d *AlarmData)
- func StartSpan(name string) zipkin.Span
- func StartSpanP(ctx model.SpanContext, name string) zipkin.Span
- func StartSpanR(r *http.Request, name string) zipkin.Span
- func StopSpan(span zipkin.Span)
- func String(key string, value interface{}) zap.Field
- func Warn(template string, args ...interface{})
- func WarnF(r *http.Request, title string, template string, args ...interface{})
- func WithRequest(r *http.Request) context.Context
- func WithValue(value string) context.Context
- type AlarmAt
- type AlarmData
- type AlarmMarkdown
- type AlarmMsg
- type AlarmText
- type Config
- type CusLog
- func (l *CusLog) Error(template string, args ...interface{})
- func (l *CusLog) ErrorF(r *http.Request, title string, template string, args ...interface{})
- func (l *CusLog) Info(template string, args ...interface{})
- func (l *CusLog) InfoF(r *http.Request, title string, template string, args ...interface{})
- func (l *CusLog) Warn(template string, args ...interface{})
- func (l *CusLog) WarnF(r *http.Request, title string, template string, args ...interface{})
- type GormCtx
- type LogOptionFunc
- func SetLogAppMode(appMode string) LogOptionFunc
- func SetLogAppName(appName string) LogOptionFunc
- func SetLogChildPath(childPath string) LogOptionFunc
- func SetLogMaxAge(maxAge time.Duration) LogOptionFunc
- func SetLogMaxSize(size int64) LogOptionFunc
- func SetLogPath(logPath string) LogOptionFunc
- func SetLogType(logType string) LogOptionFunc
- func SetNoBuffWriter() LogOptionFunc
- func SetRotationCount(n uint) LogOptionFunc
- func SetRotationTime(rotationTime time.Duration) LogOptionFunc
- type Trace
Constants ¶
View Source
const ( DefaultAppName = "default-app" // 默认应用名称 DefaultAppMode = "dev" // 默认应用环境 DefaultLogType = "file" // 默认日志类型 DefaultLogPath = "/home/logs/app" // 默认文件目录 DefaultChildPath = "glogs/%Y-%m-%d.log" // 默认子目录 DefaultRotationSize = 32 * 1024 * 1024 // 默认大小为32M DefaultRotationCount = 0 // 默认不限制 DefaultRotationTime = 24 * time.Hour // 默认每天轮转一次 DefaultNoBuffWrite = false // 不不开启无缓冲写入 DefaultMaxAge = 90 * 24 * time.Hour // 默认保留90天 LevelInfo = "info" LevelWarn = "warn" LevelError = "error" )
Variables ¶
View Source
var ( RequestIDName = "x-b3-traceid" HeaderAppName = "app-name" KeyPath = "path" KeyTitle = "title" KeyOriginAppName = "origin_app_name" )
View Source
var ( Sugar *zap.Logger DefaultConfig = &Config{ appName: DefaultAppName, appMode: DefaultAppMode, logType: DefaultLogType, logPath: DefaultLogPath, childPath: DefaultChildPath, RotationSize: DefaultRotationSize, RotationCount: DefaultRotationCount, NoBuffWrite: DefaultNoBuffWrite, RotationTime: DefaultRotationTime, MaxAge: DefaultMaxAge, } )
View Source
var DingCh = make(chan *AlarmData, 10)
View Source
var SpanContextKey = "default_app_context_span"
SpanContextKey ctx key,约定ctx的key名称
View Source
var SqlLogger = "sql_logger"
View Source
var Tracer *zipkin.Tracer
Tracer 引擎
Functions ¶
func GetSpanContextKey ¶
func GetSpanContextKey() string
func GetWriter ¶
GetWriter 按天切割按大小切割 filename 文件名 RotationSize 每个文件的大小 MaxAge 文件最大保留天数 RotationCount 最大保留文件个数 RotationTime 设置文件分割时间 RotationCount 设置保留的最大文件数量
func InitLog ¶
func InitLog(options ...LogOptionFunc)
InitLog 初始化日志文件 logPath= /home/logs/app/appName/childPath
func StartSpanP ¶
func StartSpanP(ctx model.SpanContext, name string) zipkin.Span
Types ¶
type AlarmData ¶
type AlarmMarkdown ¶
type AlarmMsg ¶
type AlarmMsg struct { MsgType string `json:"msgtype"` Text AlarmText `json:"text"` Markdown AlarmMarkdown `json:"markdown"` At AlarmAt `json:"at"` }
type LogOptionFunc ¶
type LogOptionFunc func(*Config)
func SetLogChildPath ¶
func SetLogChildPath(childPath string) LogOptionFunc
设置子目录—+文件名,保证一个类型的文件在同一个文件夹下面便于区分、默认值glogs/%Y-%m-%d.log
func SetLogMaxAge ¶
func SetLogMaxAge(maxAge time.Duration) LogOptionFunc
SetLogMaxAge 设置文件最大保留时间、默认值7天
func SetLogPath ¶
func SetLogPath(logPath string) LogOptionFunc
设置日志目录,这个是主目录,程序会给此目录拼接上项目名,子目录以及文件,默认值/home/logs/app
func SetLogType ¶
func SetLogType(logType string) LogOptionFunc
设置日志类型,日志类型目前分为2种,console和file,默认值file
func SetRotationCount ¶
func SetRotationCount(n uint) LogOptionFunc
SetRotationCount 设置保留的最大文件数量、没有默认值(表示不限制)
func SetRotationTime ¶
func SetRotationTime(rotationTime time.Duration) LogOptionFunc
SetRotationTime 设置文件分割时间、默认值24*time.Hour(按天分割)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
package rotatelogs is a port of File-RotateLogs from Perl (https://metacpan.org/release/File-RotateLogs), and it allows you to automatically rotate output files when you write to them according to the filename pattern that you can specify.
|
package rotatelogs is a port of File-RotateLogs from Perl (https://metacpan.org/release/File-RotateLogs), and it allows you to automatically rotate output files when you write to them according to the filename pattern that you can specify. |
Click to show internal directories.
Click to hide internal directories.