Documentation
¶
Overview ¶
Package log .
this log is inspired by `https://github.com/silenceper/log` and `https://github.com/sirupsen/logrus` 1. can be set to output to file 2. log file can be splitted into files day by day, just like `app.20060102.log`
Index ¶
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func GetCallerForTest() *runtime.Frame
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func SetCallerReporter(b bool)
- func SetLogLevel(level Level)
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func WithField(key string, value interface{}) *entry
- func WithFields(fields Fields) *entry
- type Fields
- type Formatter
- type Level
- type Logger
- func (l *Logger) Debug(args ...interface{})
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Fatal(args ...interface{})
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Info(args ...interface{})
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) SetCallerReporter(b bool)
- func (l *Logger) SetLogLevel(level Level)
- func (l *Logger) Warn(args ...interface{})
- func (l *Logger) Warnf(format string, args ...interface{})
- func (l *Logger) WithField(key string, value interface{}) *entry
- func (l *Logger) WithFields(fields Fields) *entry
- type LoggerOption
- type TextFormatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetCallerReporter ¶ added in v1.0.3
func SetCallerReporter(b bool)
Types ¶
type Fields ¶ added in v1.0.0
type Fields map[string]interface{}
Fields to contains a batch field to log
type Logger ¶ added in v1.0.0
type Logger struct {
// contains filtered or unexported fields
}
func NewLogger ¶
func NewLogger(opts ...LoggerOption) (*Logger, error)
NewLogger using os.Stdout and LevelDebug to print log
func (*Logger) SetCallerReporter ¶ added in v1.0.3
func (*Logger) SetLogLevel ¶ added in v1.0.0
func (*Logger) WithFields ¶ added in v1.0.0
type LoggerOption ¶ added in v1.0.0
type LoggerOption func(lo *options) error
LoggerOption to apply single function into `lo`
func WithCustomWriter ¶ added in v1.0.1
func WithCustomWriter(w io.Writer) LoggerOption
WithCustomWriter using custom writer to log
func WithFileLog ¶ added in v1.0.0
func WithFileLog(file string, autoRotate bool) LoggerOption
WithFileLog store log into file, if autoRotate is set, it will start a goroutine to split log file by day. TODO(@yeqown): using time round instead of ticker
func WithGlobalFields ¶ added in v1.0.0
func WithGlobalFields(fields Fields) LoggerOption
WithGlobalFields set global fields those would be logged in every log.
func WithLevel ¶ added in v1.0.0
func WithLevel(lv Level) LoggerOption
WithLevel setting the level, this could change dynamic
func WithReportCaller ¶ added in v1.0.3
func WithReportCaller(b bool) LoggerOption
func WithStdout ¶ added in v1.0.0
func WithStdout(v bool) LoggerOption
WithStdout output to os.Stdout this only affect when file log is opening
type TextFormatter ¶ added in v1.0.0
type TextFormatter struct {
// contains filtered or unexported fields
}
func (*TextFormatter) Format ¶ added in v1.0.0
func (f *TextFormatter) Format(e *entry) ([]byte, error)
Format entry into log

