Documentation ¶
Overview ¶
Package logger 封装的go.uber.org/zap包 方便日志管理和使用
Index ¶
- Variables
- func FlushAndCloseLogger(name string) error
- func GetGID() uint64
- func GetLogger(name string) *zap.Logger
- func InitLogger(path string, logLevel Level, location *time.Location, gid *sync.Map) error
- func InitLoggerWithConfig(cfg Config, location *time.Location, gid *sync.Map) error
- func InitLoggerWithLevel(path string, logLevel LevelString, location *time.Location, gid *sync.Map) error
- func ToEarlyMorningTimeDuration(now time.Time) time.Duration
- type Config
- type GIDContext
- type Level
- type LevelString
- type Logger
Constants ¶
This section is empty.
Variables ¶
View Source
var (
Empty = &emptyLogger{}
)
Empty empty logger.
Functions ¶
func FlushAndCloseLogger ¶
FlushAndCloseLogger flush and close logger.
func InitLogger ¶
InitLogger 初始化. path 输出路径, 默认当前路径. logLevel 日志级别. location 日志文件名所属时区.
func InitLoggerWithConfig ¶
InitLoggerWithConfig 使用config初始化logger.
func InitLoggerWithLevel ¶
func InitLoggerWithLevel(path string, logLevel LevelString, location *time.Location, gid *sync.Map) error
InitLoggerWithLevel 使用String格式的level初始化logger. path 输出路径, 默认当前路径. logLevel 日志级别: debug,info,warn. location 日志文件名所属时区.
Types ¶
type Config ¶
type Config struct { Loglevel LevelString StdOut bool // 如果true,则 path、maxsize失效 Path string // MaxSize 单文件最大存储,单位MB MaxSize int }
Config logger config.
type GIDContext ¶ added in v1.0.4
type GIDContext struct {
// contains filtered or unexported fields
}
func (*GIDContext) Debugw ¶ added in v1.0.4
func (g *GIDContext) Debugw(msg string, kv ...interface{})
func (*GIDContext) Errorw ¶ added in v1.0.4
func (g *GIDContext) Errorw(msg string, kv ...interface{})
func (*GIDContext) Infow ¶ added in v1.0.4
func (g *GIDContext) Infow(msg string, kv ...interface{})
func (*GIDContext) Panicw ¶ added in v1.0.4
func (g *GIDContext) Panicw(msg string, kv ...interface{})
func (*GIDContext) Warnw ¶ added in v1.0.4
func (g *GIDContext) Warnw(msg string, kv ...interface{})
type LevelString ¶
type LevelString string
LevelString 字符串格式的Level.
const ( // DebugStringLevel debug. DebugStringLevel LevelString = "debug" // InfoStringLevel info. InfoStringLevel LevelString = "info" // WarnStringLevel warn. WarnStringLevel LevelString = "warn" // ErrorStringLevel error. ErrorStringLevel LevelString = "error" )
Click to show internal directories.
Click to hide internal directories.