Documentation ¶
Index ¶
- Constants
- Variables
- func DataLog(topic string, keysAndValues ...interface{})
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Debugw(msg string, keysAndValues ...interface{})
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Errorw(msg string, keysAndValues ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func GetLogger() *log.Logger
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Infow(msg string, keysAndValues ...interface{})
- func InitData(path string, rolling RollingFormat) error
- func InitDataWithKey(path string, rolling RollingFormat, task string) error
- func MilliSecondTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func NewConsoleEncoder(cfg *zapcore.EncoderConfig) zapcore.Encoder
- func NewRollingFile(basePath string, rolling RollingFormat) (*rollingFile, error)
- func NewTimeEncoder(timeFormat string) func(time.Time, zapcore.PrimitiveArrayEncoder)
- func SetLevelByString(level string)
- func SetOutputByName(path string)
- func SetOutputPath(dir string)
- func SetRotateByDay()
- func SetRotateByHour()
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- func Warning(v ...interface{})
- func Warningf(format string, v ...interface{})
- func Warningw(msg string, keysAndValues ...interface{})
- func Warnw(msg string, keysAndValues ...interface{})
- type Logger
- func DataWith(args ...interface{}) *Logger
- func For(ctx context.Context, args ...interface{}) *Logger
- func GetMyLogger(name string) *Logger
- func Log(name string) *Logger
- func New() *Logger
- func NewJSON(path string, rolling RollingFormat) (*Logger, error)
- func NewLogger(opt *Options, paths ...string) *Logger
- func With(args ...interface{}) *Logger
- func (l *Logger) GetOutput() io.Writer
- func (l *Logger) Logger() *log.Logger
- func (l *Logger) SetColors(color bool)
- func (l *Logger) SetFlags(flags int)
- func (l *Logger) SetHighlighting(highlighting bool)
- func (l *Logger) SetLevel(level int)
- func (l *Logger) SetLevelByString(level string)
- func (l *Logger) SetLogPrefix(prefix string)
- func (l *Logger) SetOutput(out io.Writer)
- func (l *Logger) SetOutputByName(path string) error
- func (l *Logger) SetOutputPath(path string) error
- func (l *Logger) SetPrintLevel(printLevel bool)
- func (l *Logger) SetRotateByDay()
- func (l *Logger) SetRotateByHour()
- func (l *Logger) SetRotateBySecond()
- func (l *Logger) SetTimeFmt(fmt string) error
- type Options
- type RollingFormat
Constants ¶
View Source
const ( TIMENANO = "2006-01-02 15:04:05.9999999" TIMEMICRO = "2006-01-02 15:04:05.999" TIMESECOND = "2006-01-02 15:04:05" DAILY = "20060102" HOURLY = "2006010215" SECONDLY = "200601021505" )
View Source
const ( MonthlyRolling RollingFormat = "200601" DailyRolling = "20060102" HourlyRolling = "2006010215" MinutelyRolling = "200601021504" SecondlyRolling = "20060102150405" )
View Source
const (
DefaultLoggerName = "_default"
)
Logger name for default loggers
Variables ¶
View Source
var ErrClosedRollingFile = errors.New("rolling file is closed")
Functions ¶
func InitDataWithKey ¶
func InitDataWithKey(path string, rolling RollingFormat, task string) error
InitDataWithKey logger
func MilliSecondTimeEncoder ¶
func MilliSecondTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
func NewConsoleEncoder ¶
func NewConsoleEncoder(cfg *zapcore.EncoderConfig) zapcore.Encoder
func NewRollingFile ¶
func NewRollingFile(basePath string, rolling RollingFormat) (*rollingFile, error)
func NewTimeEncoder ¶
func NewTimeEncoder(timeFormat string) func(time.Time, zapcore.PrimitiveArrayEncoder)
func SetLevelByString ¶
func SetLevelByString(level string)
func SetOutputByName ¶
func SetOutputByName(path string)
func SetOutputPath ¶
func SetOutputPath(dir string)
func SetRotateByDay ¶
func SetRotateByDay()
func SetRotateByHour ¶
func SetRotateByHour()
Types ¶
type Logger ¶
type Logger struct { *zap.SugaredLogger // contains filtered or unexported fields }
Logger...
func GetMyLogger ¶
func NewJSON ¶
func NewJSON(path string, rolling RollingFormat) (*Logger, error)
NewJSON build json data format logger
func (*Logger) SetHighlighting ¶
func (*Logger) SetLevelByString ¶
func (*Logger) SetLogPrefix ¶
func (*Logger) SetOutputByName ¶
func (*Logger) SetOutputPath ¶
func (*Logger) SetPrintLevel ¶
func (*Logger) SetRotateByDay ¶
func (l *Logger) SetRotateByDay()
func (*Logger) SetRotateByHour ¶
func (l *Logger) SetRotateByHour()
func (*Logger) SetRotateBySecond ¶
func (l *Logger) SetRotateBySecond()
func (*Logger) SetTimeFmt ¶
type Options ¶
type Options struct { // There are five logging level // "debug","info","warning","error","fatal", debug is default value Level string Prefix string // Enable logging the full timestamp when a TTY is attached instead of just // the time passed since beginning of execution. DisableFullTimestamp bool // TimesFormat to use for display when a full timestamp is printed TimesFormat string // Whether printf level string when logging or not DisableLevel bool // Force disabling colors. DisableColors bool DisableTimestamp bool // "daily", "hourly", default is not rolling Rolling string // This option will not wrap empty fields in quotes if true DisableQuoteEmptyFields bool // The fields are sorted by default for a consistent output. // Not sorting is default value. Sorting bool }
type RollingFormat ¶
type RollingFormat string
Click to show internal directories.
Click to hide internal directories.