Versions in this module Expand all Collapse all v0 v0.3.8 Dec 5, 2023 Changes in this version + const Day + const SocketDefaultDelay + const SocketDefaultMaxDeadline + const SocketDefaultTimeout + const UnlimitedDeadline + const UnlimitedDelay + const Week + var ErrorInvalidFormat = errors.New("invalid format") + var ErrorNoSuchLevel = errors.New("no such level") + var FileModeNameToValues = map[string]int + var ForceRetryError error = errors.New("force to retry") + var RetryFailedError = errors.New("retry failed") + var SyslogNameToPriorities = map[string]syslog.Priority — darwin/amd64, js/wasm, linux/amd64 + var UnknownCallerInfo = &CallerInfo + func AddLevel(level LogLevelType, levelName string) + func ApplyConfigFile(file string) error + func ApplyJsonConfigFile(file string) error + func ApplyYAMLConfigFile(file string) error + func ConfigFilters(m ConfMap, i Filterer, env *ConfEnv) error + func ConfigFormatters(m ConfMap, i SetFormatterable, env *ConfEnv) error + func ConfigHandlers(m ConfMap, i AddHandlerable, env *ConfEnv) error + func ConfigLevel(m ConfMap, i SetLevelable) error + func ConfigLogger(m ConfMap, logger Logger, isRoot bool, env *ConfEnv) error + func Debugf(format string, args ...interface{}) + func DictConfig(conf *Conf) error + func Errorf(format string, args ...interface{}) + func Fatalf(format string, args ...interface{}) + func FileExists(filename string) bool + func GetLevelName(level LogLevelType) (name string) + func Infof(format string, args ...interface{}) + func IsNil(i interface{}) bool + func IsNotNil(i interface{}) bool + func Logf(level LogLevelType, format string, args ...interface{}) + func Min(a, b int64) int64 + func Print(args ...interface{}) + func RandIntN(n int) int + func ReadN(reader io.Reader, b []byte) (int, error) + func SetLoggerMaker(maker LoggerMaker) + func Shutdown() + func Tracef(format string, args ...interface{}) + func Warnf(format string, args ...interface{}) + func WriteN(writer io.Writer, b []byte) (int, error) + type AddHandlerable interface + AddHandler func(handler Handler) + type BaseBufferingHandler struct + func NewBaseBufferingHandler(capacity uint64) *BaseBufferingHandler + func (self *BaseBufferingHandler) Close() + func (self *BaseBufferingHandler) Emit2(handler BufferingHandler, record *LogRecord) error + func (self *BaseBufferingHandler) Flush() error + func (self *BaseBufferingHandler) GetBuffer() *list.List + func (self *BaseBufferingHandler) ShouldFlush(_ *LogRecord) bool + type BaseHandler struct + func NewBaseHandler(name string, level LogLevelType) *BaseHandler + func (self *BaseHandler) Close() + func (self *BaseHandler) Flush() error + func (self *BaseHandler) Format(record *LogRecord) string + func (self *BaseHandler) GetLevel() LogLevelType + func (self *BaseHandler) GetName() string + func (self *BaseHandler) Handle2(handler Handler, record *LogRecord) int + func (self *BaseHandler) HandleError(_ *LogRecord, _ error) + func (self *BaseHandler) Lock() + func (self *BaseHandler) SetFormatter(formatter Formatter) + func (self *BaseHandler) SetLevel(level LogLevelType) error + func (self *BaseHandler) SetName(name string) + func (self *BaseHandler) Unlock() + type BaseRotatingHandler struct + func NewBaseRotatingHandler(filepath string, mode, bufferSize int) (*BaseRotatingHandler, error) + func (self *BaseRotatingHandler) RolloverEmit(handler RotatingHandler, record *LogRecord) error + type BoundedExponentialBackoffRetry struct + func NewBoundedExponentialBackoffRetry(sleepFunc func(time.Duration), maxTries uint32, baseSleepTime time.Duration, ...) *BoundedExponentialBackoffRetry + func (self *BoundedExponentialBackoffRetry) Do(fn func() error) error + type BufferingFormatter struct + func NewBufferingFormatter(lineFormatter Formatter) *BufferingFormatter + func (self *BufferingFormatter) Format(records []*LogRecord) string + func (self *BufferingFormatter) FormatFooter(_ []*LogRecord) string + func (self *BufferingFormatter) FormatHeader(_ []*LogRecord) string + type BufferingHandler interface + ShouldFlush func(record *LogRecord) bool + type CallerInfo struct + FileName string + FuncName string + LineNo uint32 + PathName string + type Conf struct + Filters map[string]ConfFilter + Formatters map[string]ConfFormatter + Handlers map[string]ConfMap + Loggers map[string]ConfMap + Root ConfMap + Version int + type ConfEnv struct + func NewConfigEnv() *ConfEnv + type ConfFilter struct + Name string + type ConfFormatter struct + DateFormat *string + Format *string + type ConfMap map[string]interface + func (self ConfMap) GetBool(key string) (bool, error) + func (self ConfMap) GetInt(key string) (int, error) + func (self ConfMap) GetString(key string) (string, error) + func (self ConfMap) GetUint16(key string) (uint16, error) + func (self ConfMap) GetUint32(key string) (uint32, error) + func (self ConfMap) GetUint64(key string) (uint64, error) + type DatagramHandler struct + func NewDatagramHandler(host string, port uint16) *DatagramHandler + type ErrorRetry struct + func NewErrorRetry() *ErrorRetry + func (self *ErrorRetry) Backoff(backoff uint32) *ErrorRetry + func (self *ErrorRetry) Copy() *ErrorRetry + func (self *ErrorRetry) Deadline(deadline time.Duration) *ErrorRetry + func (self *ErrorRetry) Delay(delay time.Duration) *ErrorRetry + func (self *ErrorRetry) Do(fn func() error) error + func (self *ErrorRetry) MaxDelay(maxDelay time.Duration) *ErrorRetry + func (self *ErrorRetry) MaxJitter(maxJitter float32) *ErrorRetry + func (self *ErrorRetry) MaxTries(maxTries int) *ErrorRetry + func (self *ErrorRetry) OnError(err error) *ErrorRetry + func (self *ErrorRetry) SleepFunc(fn func(time.Duration)) *ErrorRetry + type ExponentialBackoffRetry struct + func NewExponentialBackoffRetry(sleepFunc func(time.Duration), baseSleepTime time.Duration, ...) *ExponentialBackoffRetry + func (self *ExponentialBackoffRetry) Do(fn func() error) error + type ExtractAttr func(record *LogRecord) string + type FileHandler struct + func NewFileHandler(filename string, mode int, bufferSize int) (*FileHandler, error) + func (self *FileHandler) Close() + func (self *FileHandler) Emit(record *LogRecord) error + func (self *FileHandler) GetFilePath() string + func (self *FileHandler) Handle(record *LogRecord) int + func (self *FileHandler) Open() error + type FileStream struct + Buffer *bytes.Buffer + BufferSize int + File *os.File + Offset int64 + func NewFileStream(f *os.File, bufferSize int) *FileStream + func (self *FileStream) Close() error + func (self *FileStream) Flush() error + func (self *FileStream) Tell() (int64, error) + func (self *FileStream) Write(s string) error + type Filter interface + Filter func(record *LogRecord) bool + type Filterer interface + AddFilter func(filter Filter) + Filter func(record *LogRecord) int + RemoveFilter func(filter Filter) + type FindCallerFunc func() *CallerInfo + type Formatter interface + Format func(record *LogRecord) string + type GetFormatArgsFunc func(record *LogRecord) []interface + type HandleFunc func(record *LogRecord) int + type Handler interface + Close func() + Emit func(record *LogRecord) error + Flush func() error + GetLevel func() LogLevelType + GetName func() string + Handle func(record *LogRecord) int + HandleError func(record *LogRecord, err error) + SetFormatter func(formatter Formatter) + SetLevel func(level LogLevelType) error + SetName func(name string) + type HandlerCloser struct + var Closer *HandlerCloser + func NewHandlerCloser() *HandlerCloser + func (self *HandlerCloser) AddHandler(handler Handler) + func (self *HandlerCloser) Close() + func (self *HandlerCloser) RemoveHandler(handler Handler) + type ListSet struct + func NewListSet() *ListSet + func (self *ListSet) SetAdd(i interface{}) + func (self *ListSet) SetClone() *ListSet + func (self *ListSet) SetContains(i interface{}) bool + func (self *ListSet) SetRemove(i interface{}) bool + type LogLevelType uint8 + const LevelCritical + const LevelDebug + const LevelError + const LevelFatal + const LevelInfo + const LevelNotset + const LevelTrace + const LevelWarn + const LevelWarning + func GetNameLevel(name string) (level LogLevelType, ok bool) + func (level LogLevelType) String() string + type LogRecord struct + Args []interface{} + AscTime string + CreatedTime time.Time + FileName string + Format string + FuncName string + Level LogLevelType + LineNo uint32 + Message string + Name string + PathName string + UseFormat bool + func NewLogRecord(name string, level LogLevelType, pathName string, fileName string, ...) *LogRecord + func (self *LogRecord) GetMessage() string + func (self *LogRecord) String() string + type Logger interface + AddHandler func(handler Handler) + CallHandlers func(record *LogRecord) + Debug func(args ...interface{}) + Debugf func(format string, args ...interface{}) + Error func(args ...interface{}) + Errorf func(format string, args ...interface{}) + Fatal func(args ...interface{}) + Fatalf func(format string, args ...interface{}) + GetEffectiveLevel func() LogLevelType + GetHandlers func() []Handler + GetLevel func() LogLevelType + GetManager func() *Manager + GetName func() string + GetParent func() Logger + GetPropagate func() bool + Info func(args ...interface{}) + Infof func(format string, args ...interface{}) + IsEnabledFor func(level LogLevelType) bool + Log func(level LogLevelType, args ...interface{}) + Logf func(level LogLevelType, format string, args ...interface{}) + Print func(args ...interface{}) + RemoveHandler func(handler Handler) + SetLevel func(level LogLevelType) error + SetManager func(manager *Manager) + SetParent func(parent Logger) + SetPropagate func(v bool) + Trace func(args ...interface{}) + Tracef func(format string, args ...interface{}) + Warn func(args ...interface{}) + Warnf func(format string, args ...interface{}) + func GetLogger(name string) Logger + type LoggerMaker func(name string) Logger + type Manager struct + func NewManager(logger Logger) *Manager + func (self *Manager) GetLogger(name string) Logger + func (self *Manager) SetLoggerMaker(maker LoggerMaker) + type MemoryHandler struct + func NewMemoryHandler(capacity uint64, flushLevel LogLevelType, target Handler) *MemoryHandler + func (self *MemoryHandler) Close() + func (self *MemoryHandler) Emit(record *LogRecord) error + func (self *MemoryHandler) Flush() error + func (self *MemoryHandler) Handle(record *LogRecord) int + func (self *MemoryHandler) SetTarget(target Handler) + func (self *MemoryHandler) ShouldFlush(record *LogRecord) bool + type NTimesRetry struct + func NewNTimesRetry(sleepFunc func(time.Duration), maxTimes uint32, ...) *NTimesRetry + func (self *NTimesRetry) Do(fn func() error) error + type NameFilter struct + func NewNameFilter(name string) *NameFilter + func (self *NameFilter) Filter(record *LogRecord) bool + type Node interface + Type func() NodeType + type NodeType uint8 + const NodeLogger + const NodePlaceHolder + const NodeUnknown + type NullHandler struct + func NewNullHandler() *NullHandler + func (self *NullHandler) Emit(_ *LogRecord) error + func (self *NullHandler) Handle(_ *LogRecord) int + type OnceRetry struct + func NewOnceRetry(sleepFunc func(time.Duration), sleepTimeBetweenRetries time.Duration) *OnceRetry + type PlaceHolder struct + Loggers *ListSet + func NewPlaceHolder(logger Logger) *PlaceHolder + func (self *PlaceHolder) Append(logger Logger) + func (self *PlaceHolder) Type() NodeType + type Retry interface + Do func(func() error) error + type RootLogger struct + func NewRootLogger(level LogLevelType) *RootLogger + type RotatingFileHandler struct + func MustNewRotatingFileHandler(filepath string, mode int, bufferSize int, bufferFlushTime time.Duration, ...) *RotatingFileHandler + func NewRotatingFileHandler(filepath string, mode int, bufferSize int, bufferFlushTime time.Duration, ...) (*RotatingFileHandler, error) + func (self *RotatingFileHandler) Close() + func (self *RotatingFileHandler) DoRollover() (err error) + func (self *RotatingFileHandler) Emit(record *LogRecord) error + func (self *RotatingFileHandler) Handle(record *LogRecord) int + func (self *RotatingFileHandler) RotateFile(sourceFile, destFile string) error + func (self *RotatingFileHandler) ShouldRollover(record *LogRecord) (bool, string) + type RotatingHandler interface + DoRollover func() error + ShouldRollover func(record *LogRecord) (doRollover bool, message string) + type SetFormatterable interface + SetFormatter func(formatter Formatter) + type SetLevelable interface + SetLevel func(level LogLevelType) error + type SocketHandler struct + func NewSocketHandler(host string, port uint16) *SocketHandler + func (self *SocketHandler) Close() + func (self *SocketHandler) Emit(record *LogRecord) error + func (self *SocketHandler) Handle(record *LogRecord) int + func (self *SocketHandler) HandleError(record *LogRecord, err error) + func (self *SocketHandler) Marshal(record *LogRecord) ([]byte, error) + type SocketLogRecord struct + AscTime string + CreatedTime time.Time + FileName string + Format string + FuncName string + Level LogLevelType + LineNo uint32 + Message string + Name string + PathName string + UseFormat bool + type StandardFilterer struct + func NewStandardFilterer() *StandardFilterer + func (self *StandardFilterer) AddFilter(filter Filter) + func (self *StandardFilterer) Filter(record *LogRecord) int + func (self *StandardFilterer) GetFilters() *ListSet + func (self *StandardFilterer) RemoveFilter(filter Filter) + type StandardFormatter struct + func NewStandardFormatter(format string, dateFormat string) *StandardFormatter + func (self *StandardFormatter) Format(record *LogRecord) string + func (self *StandardFormatter) FormatAll(record *LogRecord) string + func (self *StandardFormatter) FormatTime(record *LogRecord) string + type StandardLogger struct + func NewStandardLogger(name string, level LogLevelType) *StandardLogger + func (self *StandardLogger) AddHandler(handler Handler) + func (self *StandardLogger) CallHandlers(record *LogRecord) + func (self *StandardLogger) Debug(args ...interface{}) + func (self *StandardLogger) Debugf(format string, args ...interface{}) + func (self *StandardLogger) Error(args ...interface{}) + func (self *StandardLogger) Errorf(format string, args ...interface{}) + func (self *StandardLogger) Fatal(args ...interface{}) + func (self *StandardLogger) Fatalf(format string, args ...interface{}) + func (self *StandardLogger) GetChild(suffix string) Logger + func (self *StandardLogger) GetEffectiveLevel() LogLevelType + func (self *StandardLogger) GetHandlers() []Handler + func (self *StandardLogger) GetLevel() LogLevelType + func (self *StandardLogger) GetManager() *Manager + func (self *StandardLogger) GetName() string + func (self *StandardLogger) GetParent() Logger + func (self *StandardLogger) GetPropagate() bool + func (self *StandardLogger) Handle(record *LogRecord) + func (self *StandardLogger) Info(args ...interface{}) + func (self *StandardLogger) Infof(format string, args ...interface{}) + func (self *StandardLogger) IsEnabledFor(level LogLevelType) bool + func (self *StandardLogger) Log(level LogLevelType, args ...interface{}) + func (self *StandardLogger) Logf(level LogLevelType, format string, args ...interface{}) + func (self *StandardLogger) Pirnt(args ...interface{}) + func (self *StandardLogger) Print(args ...interface{}) + func (self *StandardLogger) RemoveHandler(handler Handler) + func (self *StandardLogger) SetFindCallerFunc(f FindCallerFunc) + func (self *StandardLogger) SetLevel(level LogLevelType) error + func (self *StandardLogger) SetManager(manager *Manager) + func (self *StandardLogger) SetParent(parent Logger) + func (self *StandardLogger) SetPropagate(v bool) + func (self *StandardLogger) Trace(args ...interface{}) + func (self *StandardLogger) Tracef(format string, args ...interface{}) + func (self *StandardLogger) Type() NodeType + func (self *StandardLogger) Warn(args ...interface{}) + func (self *StandardLogger) Warnf(format string, args ...interface{}) + type StdoutHandler struct + func NewStdoutHandler() *StdoutHandler + func (self *StdoutHandler) Close() + func (self *StdoutHandler) Emit(record *LogRecord) error + func (self *StdoutHandler) Handle(record *LogRecord) int + type StdoutStream struct + func NewStdoutStream() *StdoutStream + func (self *StdoutStream) Close() error + func (self *StdoutStream) Flush() error + func (self *StdoutStream) Tell() (int64, error) + func (self *StdoutStream) Write(s string) error + type Stream interface + Close func() error + Flush func() error + Tell func() (offset int64, err error) + Write func(s string) error + type StreamHandler struct + func NewStreamHandler(name string, level LogLevelType, stream Stream) *StreamHandler + func (self *StreamHandler) Close2() + func (self *StreamHandler) Emit(record *LogRecord) error + func (self *StreamHandler) Emit2(handler Handler, record *LogRecord) error + func (self *StreamHandler) Flush() error + func (self *StreamHandler) GetStream() Stream + func (self *StreamHandler) Handle(record *LogRecord) int + func (self *StreamHandler) SetStream(s Stream) + type SyslogHandler struct — darwin/amd64, js/wasm, linux/amd64 + func NewSyslogHandler(priority syslog.Priority, tag string) (*SyslogHandler, error) + func NewSyslogHandlerToAddr(network, raddr string, priority syslog.Priority, tag string) (*SyslogHandler, error) + func (self *SyslogHandler) Close() + func (self *SyslogHandler) Emit(record *LogRecord) error + func (self *SyslogHandler) Flush() error + func (self *SyslogHandler) Handle(record *LogRecord) int + type TimedRotatingFileHandler struct + func NewTimedRotatingFileHandler(filepath string, mode int, bufferSize int, bufferFlushTime time.Duration, ...) (*TimedRotatingFileHandler, error) + func (self *TimedRotatingFileHandler) Close() + func (self *TimedRotatingFileHandler) DoRollover() (err error) + func (self *TimedRotatingFileHandler) Emit(record *LogRecord) error + func (self *TimedRotatingFileHandler) Handle(record *LogRecord) int + func (self *TimedRotatingFileHandler) ShouldRollover(record *LogRecord) (bool, string) + type UntilElapsedRetry struct + func NewUntilElapsedRetry(sleepFunc func(time.Duration), sleepTimeBetweenRetries time.Duration, ...) *UntilElapsedRetry + func (self *UntilElapsedRetry) Do(fn func() error) error