Documentation
¶
Index ¶
- func AppID() string
- func AppVersion() string
- func BuildHost() string
- func BuildTime() string
- func BuildUser() string
- func Debug(a ...interface{})
- func DebugW(template string, a ...Field)
- func Debugf(template string, a ...interface{})
- func Error(a ...interface{})
- func ErrorW(template string, a ...Field)
- func Errorf(format string, a ...interface{})
- func Fatal(a ...interface{})
- func FatalW(template string, a ...Field)
- func Fatalf(format string, a ...interface{})
- func FirstUpper(s string) string
- func GoVersion() string
- func HostName() string
- func Info(a ...interface{})
- func InfoW(template string, a ...Field)
- func Infof(template string, a ...interface{})
- func ModuleName() string
- func PkgVersion() string
- func Printf(format string, args ...interface{})
- func ServiceName() string
- func SetAppID(s string)
- func SetBuildTime(param string)
- func SetLogger(logger Logger)
- func SetModuleName(name string)
- func SetServiceName(s string)
- func StartTime() string
- func Warn(a ...interface{})
- func WarnW(template string, a ...Field)
- func Warnf(format string, a ...interface{})
- type Config
- type Field
- func Any(key string, val interface{}) Field
- func Bool(key string, val bool) Field
- func Duration(key string, val time.Duration) Field
- func FieldAddr(value string) Field
- func FieldCost(value time.Duration) Field
- func FieldErr(err error) Field
- func FieldErrKind(value string) Field
- func FieldEvent(value string) Field
- func FieldKey(value string) Field
- func FieldMessage(value string) Field
- func FieldMethod(value string) Field
- func FieldMod(value string) Field
- func FieldName(value string) Field
- func FieldStack(value []byte) Field
- func FieldString(key, value string) Field
- func FieldType(value string) Field
- func Float64(key string, val float64) Field
- func Int(key string, val int) Field
- func Int32(key string, val int32) Field
- func Int64(key string, val int64) Field
- func String(key, val string) Field
- func UInt(key string, val uint) Field
- type FiledType
- type FiledValue
- type Helper
- func (h *Helper) Debug(args ...interface{})
- func (h *Helper) DebugW(template string, args ...Field)
- func (h *Helper) Debugf(template string, args ...interface{})
- func (h *Helper) Error(args ...interface{})
- func (h *Helper) ErrorW(template string, args ...Field)
- func (h *Helper) Errorf(template string, args ...interface{})
- func (h *Helper) Fatal(args ...interface{})
- func (h *Helper) FatalW(template string, args ...Field)
- func (h *Helper) Fatalf(template string, args ...interface{})
- func (h *Helper) Info(args ...interface{})
- func (h *Helper) InfoW(template string, args ...Field)
- func (h *Helper) Infof(template string, args ...interface{})
- func (h *Helper) Trace(args ...interface{})
- func (h *Helper) Tracef(template string, args ...interface{})
- func (h *Helper) Warn(args ...interface{})
- func (h *Helper) WarnW(template string, args ...Field)
- func (h *Helper) Warnf(template string, args ...interface{})
- type Level
- type Logger
- type Option
- type Options
- type ZapCnf
- type ZapCnfKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debugf ¶
func Debugf(template string, a ...interface{})
Debugf logs a message at `debug` level.
func FirstUpper ¶
func ModuleName ¶
func ModuleName() string
func PkgVersion ¶
func PkgVersion() string
func ServiceName ¶
func ServiceName() string
func SetLogger ¶
func SetLogger(logger Logger)
SetLogger should be called before any other log call. And it is NOT THREAD SAFE.
func SetModuleName ¶
func SetModuleName(name string)
func SetServiceName ¶
func SetServiceName(s string)
Types ¶
type Config ¶
type Config struct {
Debug bool // 本地调试模式
Level string
// writer (syslog 地址)
Net string
Addr string //remote addr of syslog
Tag string //tag of syslog
// filename is the file to write logs to. Backup log files will be retained
// in the same directory. It uses <processname>-lumberjack.log in
// os.TempDir() if empty.
Filename string
// maxSize is the maximum size in bytes of the log file before it gets
// rotated.
MaxSize int64
// maxAge is the maximum time to retain old log files based on the timestamp
// encoded in their filename. The default is not to remove old log files
// based on age.
MaxAge time.Duration
// maxBackups is the maximum number of old log files to retain. The default
// is to retain all old log files (though MaxAge may still cause them to get
// deleted.)
MaxBackups int
// localTime determines if the time used for formatting the timestamps in
// backup files is the computer's local time. The default is to use UTC
// time.
LocalTime bool
// compress determines if the rotated log files should be compressed
// using gzip. The default is not to perform compression.
Compress bool
// contains filtered or unexported fields
}
Config for redis, contains RedisStubConfig and RedisClusterConfig
func (*Config) BuildOption ¶
func (*Config) WithModuleName ¶
func (*Config) WithServiceName ¶
type FiledValue ¶
type FiledValue struct {
V interface{}
T FiledType
}
type Level ¶
type Level int8
Level is a logger level.
const ( // TraceLevel level. Designates finer-grained informational events than the Debug. TraceLevel Level = iota - 2 // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel // InfoLevel is the default logging priority. // General operational entries about what's going on inside the application. InfoLevel // WarnLevel level. Non-critical entries that deserve eyes. WarnLevel // ErrorLevel level. Logs. Used for errors that should definitely be noted. ErrorLevel // FatalLevel level. Logs and then calls `logger.Exit(1)`. highest level of severity. FatalLevel )
func GetLevel ¶
GetLevel converts a level string into a logger Level value. returns an error if the input string does not match known values.
type Logger ¶
type Logger interface {
// Init initialises options
Init(options ...Option) error
// The Logger options
Options() Options
// Fields set fields to always be logged
Fields(fields map[string]interface{}) Logger
// Log writes a log entry
Log(level Level, keyvals ...interface{})
// Logf writes a formatted log entry
Logf(level Level, format string, keyvals ...interface{})
// LogW writes a field log
LogW(level Level, msg string, args ...Field)
Printf(format string, args ...interface{})
// Level 变更
OnChangeLevel(level Level)
// String returns the name of logger
String() string
}
Logger is a logger interface.
var (
DefaultLogger Logger
)
DefaultLogger is default logger.
type Option ¶
type Option func(*Options)
func WithCallerSkipCount ¶
WithCallerSkipCount set frame count to skip
func WithFields ¶
WithFields set default fields for the logger
func WithOutput ¶
WithOutput set default output writer for the logger
func WithSetOption ¶
func WithSetOption(k, v interface{}) Option
type Options ¶
type Options struct {
// The logging level the logger should log at. default is `InfoLevel`
Level Level
// fields to always be logged
Fields map[string]interface{}
// It's common to set this to a file, or leave it default which is `os.Stderr`
Out io.Writer
// Caller skip frame count for file:line info
CallerSkipCount int
// Alternative options
Context context.Context
// syslog tag
Tag string
}
type ZapCnf ¶
type ZapCnf struct {
Debug bool //调试模式 本地打印
Level string
Net string
Addr string
Tag string
// filename is the file to write logs to. Backup log files will be retained
// in the same directory. It uses <processname>-lumberjack.log in
// os.TempDir() if empty.
Filename string
// maxSize is the maximum size in bytes of the log file before it gets
// rotated.
MaxSize int64
// maxAge is the maximum time to retain old log files based on the timestamp
// encoded in their filename. The default is not to remove old log files
// based on age.
MaxAge time.Duration
// maxBackups is the maximum number of old log files to retain. The default
// is to retain all old log files (though MaxAge may still cause them to get
// deleted.)
MaxBackups int
// localTime determines if the time used for formatting the timestamps in
// backup files is the computer's local time. The default is to use UTC
// time.
LocalTime bool
// compress determines if the rotated log files should be compressed
// using gzip. The default is not to perform compression.
Compress bool
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.