Documentation ¶
Index ¶
- Constants
- Variables
- func ConsoleInitLogger()
- func Crit(msg string, ctx ...interface{})
- func Debug(msg string, ctx ...interface{})
- func DebugDynamic(getStr GetString)
- func Debugf(format string, ctx ...interface{})
- func Error(msg string, ctx ...interface{})
- func Errorf(format string, ctx ...interface{})
- func Info(msg string, ctx ...interface{})
- func InfoDynamic(getStr GetString)
- func Infof(msg string, ctx ...interface{})
- func InitLogger()
- func Trace(msg string, ctx ...interface{})
- func Warn(msg string, ctx ...interface{})
- func Warnf(msg string, ctx ...interface{})
- type Config
- type Ctx
- type GetString
- type NothingLogger
- func (n *NothingLogger) Crit(msg string, ctx ...interface{})
- func (n *NothingLogger) Debug(msg string, ctx ...interface{})
- func (n *NothingLogger) Debugf(msg string, ctx ...interface{})
- func (n *NothingLogger) Error(msg string, ctx ...interface{})
- func (n *NothingLogger) Errorf(msg string, ctx ...interface{})
- func (n *NothingLogger) Info(msg string, ctx ...interface{})
- func (n *NothingLogger) Infof(msg string, ctx ...interface{})
- func (n *NothingLogger) Trace(msg string, ctx ...interface{})
- func (n *NothingLogger) Warn(msg string, ctx ...interface{})
- func (n *NothingLogger) Warnf(msg string, ctx ...interface{})
- type RotationLogger
Constants ¶
View Source
const ( RootBuild = "build" RootCmd = "cmd" RootCommon = "common" RootConfigure = "configure" RootCore = "core" RootInternal = "internal" RootPtnclient = "ptnclient" RootPtnjson = "ptnjson" RootStatistics = "statistics" RootVendor = "vendor" RootWallet = "wallet" LogStdout = "stdout" LogStderr = "stderr" )
Variables ¶
View Source
var DefaultConfig = Config{ OutputPaths: []string{LogStdout, "./log/all.log"}, ErrorOutputPaths: []string{LogStderr, "./log/error.log"}, LoggerLvl: "DEBUG", Encoding: "console", Development: true, RotationMaxSize: 200, RotationMaxAge: 5, MaxLogMessageLength: 1024 * 1024, }
View Source
var LogConfig = DefaultConfig
View Source
var Logger *zap.Logger
Functions ¶
func ConsoleInitLogger ¶
func ConsoleInitLogger()
func DebugDynamic ¶
func DebugDynamic(getStr GetString)
func InfoDynamic ¶
func InfoDynamic(getStr GetString)
Types ¶
type Config ¶
type Config struct { OutputPaths []string `json:"outputPaths" yaml:"outputPaths"` // output file path ErrorOutputPaths []string `json:"errorOutputPaths" yaml:"errorOutputPaths"` // error file path //OpenModule []string // open module LoggerLvl string `json:"level" yaml:"level"` // log level Encoding string `json:"encoding" yaml:"encoding"` // encoding Development bool `json:"development" yaml:"development"` RotationMaxSize int `json:"rotation_max_size" yaml:"rotation_max_size"` RotationMaxAge int `json:"rotation_max_age" yaml:"rotation_max_age"` MaxLogMessageLength int `json:"max_log_message_length" yaml:"max_log_message_length"` }
type Ctx ¶
type Ctx map[string]interface{}
Ctx is a map of key/value pairs to pass as context to a log function Use this only if you really need greater safety around the arguments you pass to the logging functions.
type NothingLogger ¶
type NothingLogger struct{}
对于有些情况,我们只希望在开发环境的时候记录Log,而在生产环境不做任何记录
func (*NothingLogger) Crit ¶
func (n *NothingLogger) Crit(msg string, ctx ...interface{})
func (*NothingLogger) Debug ¶
func (n *NothingLogger) Debug(msg string, ctx ...interface{})
func (*NothingLogger) Debugf ¶
func (n *NothingLogger) Debugf(msg string, ctx ...interface{})
func (*NothingLogger) Error ¶
func (n *NothingLogger) Error(msg string, ctx ...interface{})
func (*NothingLogger) Errorf ¶
func (n *NothingLogger) Errorf(msg string, ctx ...interface{})
func (*NothingLogger) Info ¶
func (n *NothingLogger) Info(msg string, ctx ...interface{})
func (*NothingLogger) Infof ¶
func (n *NothingLogger) Infof(msg string, ctx ...interface{})
func (*NothingLogger) Trace ¶
func (n *NothingLogger) Trace(msg string, ctx ...interface{})
func (*NothingLogger) Warn ¶
func (n *NothingLogger) Warn(msg string, ctx ...interface{})
func (*NothingLogger) Warnf ¶
func (n *NothingLogger) Warnf(msg string, ctx ...interface{})
type RotationLogger ¶ added in v1.0.2
type RotationLogger struct { Max1LogLength int64 Logger *lumberjack.Logger }
用于限制一条Log的大小
Click to show internal directories.
Click to hide internal directories.