Documentation ¶
Index ¶
- Constants
- Variables
- func Must(err error)
- type Encoder
- type KzLog
- func (l *KzLog) AddHooks(hooks ...func(entry zapcore.Entry) error)
- func (l *KzLog) Debug(args ...interface{})
- func (l *KzLog) Debugf(template string, args ...interface{})
- func (l *KzLog) Debugw(msg string, keysAndValues ...interface{})
- func (l *KzLog) Error(args ...interface{})
- func (l *KzLog) Errorf(template string, args ...interface{})
- func (l *KzLog) Errorw(msg string, keysAndValues ...interface{})
- func (l *KzLog) Fatal(args ...interface{})
- func (l *KzLog) Fatalf(template string, args ...interface{})
- func (l *KzLog) Fatalw(msg string, keysAndValues ...interface{})
- func (l *KzLog) Info(args ...interface{})
- func (l *KzLog) Infof(template string, args ...interface{})
- func (l *KzLog) Infow(msg string, keysAndValues ...interface{})
- func (l *KzLog) LevelEnablerFunc(level zapcore.Level) LevelEnablerFunc
- func (l *KzLog) Log(level Level, template string, fmtArgs []interface{}, context []interface{})
- func (l *KzLog) Options() *Option
- func (l *KzLog) SetLevel(lv kiko_logger.Level)
- func (l *KzLog) StdLog() *std.Logger
- func (l *KzLog) Sync() error
- func (l *KzLog) Warn(args ...interface{})
- func (l *KzLog) Warnf(template string, args ...interface{})
- func (l *KzLog) Warnw(msg string, keysAndValues ...interface{})
- func (l *KzLog) WithCallDepth(callDepth int) kiko_logger.Logger
- func (l *KzLog) WithContext(ctx context.Context) kiko_logger.Logger
- func (l *KzLog) WithError(err error) kiko_logger.Logger
- func (l *KzLog) WithFields(fields map[string]interface{}) kiko_logger.Logger
- type Level
- type LevelEnablerFunc
- type Option
- type Options
- func WithBasePath(path string) Options
- func WithCallerSkip(skip int) Options
- func WithConsole(enableConsole bool) Options
- func WithDisableDisk(disableDisk bool) Options
- func WithEncoder(encoder Encoder) Options
- func WithEncoderConfig(encoderConfig zapcore.EncoderConfig) Options
- func WithFields(fields map[string]interface{}) Options
- func WithFilename(filename string) Options
- func WithLevel(lv Level) Options
- func WithNamespace(name string) Options
- type RollingFile
- type RollingFormat
Constants ¶
const ( // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel = iota + 1 // 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 )
const ( MonthlyRolling RollingFormat = "200601" DailyRolling = "20060102" HourlyRolling = "2006010215" MinutelyRolling = "200601021504" SecondlyRolling = "20060102150405" )
RollingFormats
Variables ¶
var ( ErrClosedRollingFile = errors.New("rolling file is closed") ErrBuffer = errors.New("buffer exceeds the limit") )
Errors
var ( // ErrLogPathNotSet is an error that indicates the log path is not set. ErrLogPathNotSet = errors.New("log path must be set") )
Functions ¶
Types ¶
type KzLog ¶
type KzLog struct {
// contains filtered or unexported fields
}
KzLog default logger achieve
func (*KzLog) Debug ¶
func (l *KzLog) Debug(args ...interface{})
Debug uses fmt.Sprint to construct and log a message.
func (*KzLog) Debugw ¶
Debugw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
When debug-level logging is disabled, this is much faster than
s.With(keysAndValues).Debug(msg)
func (*KzLog) Error ¶
func (l *KzLog) Error(args ...interface{})
Error uses fmt.Sprint to construct and log a message.
func (*KzLog) Errorw ¶
Errorw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func (*KzLog) Fatal ¶
func (l *KzLog) Fatal(args ...interface{})
Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit. Deprecated: 记录消息后,直接调用 os.Exit(1),这意味着: 在其他 goroutine defer 语句不会被执行; 各种 buffers 不会被 flush,包括日志的; 临时文件或者目录不会被移除; 不要使用 fatal 记录日志,而是向调用者返回错误。如果错误一直持续到 main.main。main.main 那就是在退出之前做处理任何清理操作的正确位置。
func (*KzLog) Fatalf ¶
Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit. Deprecated: 记录消息后,直接调用 os.Exit(1),这意味着: 在其他 goroutine defer 语句不会被执行; 各种 buffers 不会被 flush,包括日志的; 临时文件或者目录不会被移除; 不要使用 fatal 记录日志,而是向调用者返回错误。如果错误一直持续到 main.main。main.main 那就是在退出之前做处理任何清理操作的正确位置。
func (*KzLog) Fatalw ¶
Fatalw logs a message with some additional context, then calls os.Exit. The variadic key-value pairs are treated as they are in With. Deprecated: 记录消息后,直接调用 os.Exit(1),这意味着: 在其他 goroutine defer 语句不会被执行; 各种 buffers 不会被 flush,包括日志的; 临时文件或者目录不会被移除; 不要使用 fatal 记录日志,而是向调用者返回错误。如果错误一直持续到 main.main。main.main 那就是在退出之前做处理任何清理操作的正确位置。
func (*KzLog) Info ¶
func (l *KzLog) Info(args ...interface{})
Info uses fmt.Sprint to construct and log a message.
func (*KzLog) Infow ¶
Infow logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func (*KzLog) LevelEnablerFunc ¶
func (l *KzLog) LevelEnablerFunc(level zapcore.Level) LevelEnablerFunc
func (*KzLog) Warn ¶
func (l *KzLog) Warn(args ...interface{})
Warn uses fmt.Sprint to construct and log a message.
func (*KzLog) Warnw ¶
Warnw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func (*KzLog) WithCallDepth ¶
WithCallDepth with logger call depth.
func (*KzLog) WithContext ¶
WithContext with context
func (*KzLog) WithFields ¶
WithFields set fields to always be logged
type Level ¶
type Level int8
func ParseLevel ¶
ParseLevel parses a level string into a logger Level value.
type LevelEnablerFunc ¶
LevelEnablerFunc is a convenient way to implement zapcore.LevelEnabler with an anonymous function.
It's particularly useful when splitting log output between different outputs (e.g., standard error and standard out). For sample code, see the package-level AdvancedConfiguration example.
type Options ¶
type Options func(o *Option)
func WithCallerSkip ¶
WithCallerSkip increases the number of callers skipped by caller annotation (as enabled by the AddCaller option). When building wrappers around the Logger and SugaredLogger, supplying this Option prevents base from always reporting the wrapper code as the caller.
func WithEncoderConfig ¶
func WithEncoderConfig(encoderConfig zapcore.EncoderConfig) Options
WithEncoderConfig set logger encoderConfig
func WithFields ¶
WithFields set default fields for the logger
func WithNamespace ¶
WithNamespace creates a named, isolated scope within the logger's context. All subsequent fields will be added to the new namespace.
This helps prevent key collisions when injecting loggers into sub-components or third-party libraries.
type RollingFile ¶
type RollingFile struct {
// contains filtered or unexported fields
}
RollingFile : Defination of rolling
func NewRollingFile ¶
func NewRollingFile(basePath string, rolling RollingFormat) (*RollingFile, error)
NewRollingFile create new rolling
func (*RollingFile) SetRolling ¶
func (r *RollingFile) SetRolling(fmt RollingFormat)
SetRolling : Set rolling format