log

package
v0.3.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2022 License: BSD-2-Clause Imports: 11 Imported by: 18

Documentation

Index

Constants

View Source
const COUNTER_SEP = "-"

Variables

This section is empty.

Functions

func AsyncWriter

func AsyncWriter(ch chan string, writer io.Writer)

func Shutdown

func Shutdown()

Types

type Console

type Console struct {
	RootAppender
}

func NewConsoleAppender

func NewConsoleAppender(async bool) *Console

type FileAppender

type FileAppender struct {
	RootAppender
	// contains filtered or unexported fields
}

Resets the log file as soon it goe over the maxsize. If maxsize == 0, then the log file will never reset.

func NewFileAppender

func NewFileAppender(file string, size int64, resetOnStartup bool, async bool) *FileAppender

func (*FileAppender) Write

func (this *FileAppender) Write(p []byte) (n int, err error)

type ILogger

type ILogger interface {
	IsActive(LogLevel) bool
	CallerAt(depth int) ILogger
	Tracef(string, ...interface{})
	Debugf(string, ...interface{})
	Infof(string, ...interface{})
	Warnf(string, ...interface{})
	Errorf(string, ...interface{})
	Fatalf(string, ...interface{})
}

type LogHandler

type LogHandler struct {
	Message string
	Worker  *Worker
}

type LogLevel

type LogLevel int
const (
	ALL LogLevel = iota
	TRACE
	DEBUG
	INFO
	WARN
	ERROR
	FATAL
	NONE
)

func ParseLevel

func ParseLevel(name string, optional LogLevel) LogLevel

func (LogLevel) String

func (this LogLevel) String() string

type LogMaster

type LogMaster struct {
	// contains filtered or unexported fields
}

type LogWriter

type LogWriter interface {
	Discard()
	Log(LogLevel, string)
}

type Logger

type Logger struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func LoggerFor

func LoggerFor(namespace string) *Logger

func RootLogger

func RootLogger() *Logger

func (*Logger) CallerAt

func (this *Logger) CallerAt(depth int) ILogger

func (*Logger) Debug

func (this *Logger) Debug(a ...interface{})

func (*Logger) Debugf

func (this *Logger) Debugf(format string, what ...interface{})

func (*Logger) Error

func (this *Logger) Error(a ...interface{})

func (*Logger) Errorf

func (this *Logger) Errorf(format string, what ...interface{})

func (*Logger) Fatal

func (this *Logger) Fatal(a ...interface{})

func (*Logger) Fatalf

func (this *Logger) Fatalf(format string, what ...interface{})

func (*Logger) Info

func (this *Logger) Info(a ...interface{})

func (*Logger) Infof

func (this *Logger) Infof(format string, what ...interface{})

func (*Logger) IsActive

func (this *Logger) IsActive(level LogLevel) bool

func (*Logger) Level

func (this *Logger) Level() LogLevel

func (*Logger) Namespace

func (this *Logger) Namespace() string

func (*Logger) SetCallerAt

func (this *Logger) SetCallerAt(depth int) *Logger

func (*Logger) Trace

func (this *Logger) Trace(a ...interface{})

func (*Logger) Tracef

func (this *Logger) Tracef(format string, what ...interface{})

func (*Logger) Warn

func (this *Logger) Warn(a ...interface{})

func (*Logger) Warnf

func (this *Logger) Warnf(format string, what ...interface{})

type NullAppender

type NullAppender struct{}

func NewNullAppender

func NewNullAppender() *NullAppender

func (*NullAppender) Discard

func (this *NullAppender) Discard()

func (*NullAppender) Log

func (this *NullAppender) Log(msgLevel LogLevel, msg string)

type RollingFileAppender

type RollingFileAppender struct {
	RootAppender
	// contains filtered or unexported fields
}

Roll the log file over a range of files once they go over the maxsize. If maxsize == 0, then the log file will never rool. If count == 0, then the backup log files will be infinite. The format of the backup log files will be <name>-<counter>.<extension>

func NewRollingFileAppender

func NewRollingFileAppender(file string, size int64, count int, async bool) *RollingFileAppender

func (*RollingFileAppender) Write

func (this *RollingFileAppender) Write(p []byte) (n int, err error)

type RootAppender

type RootAppender struct {
	io.Writer
	Channel chan string
}

func (*RootAppender) Discard

func (this *RootAppender) Discard()

func (*RootAppender) DrainChannel

func (this *RootAppender) DrainChannel()

func (*RootAppender) Log

func (this *RootAppender) Log(msgLevel LogLevel, msg string)

type Worker

type Worker struct {
	Prefix  string
	Level   LogLevel
	Writers []LogWriter
	// contains filtered or unexported fields
}

func Register

func Register(namespace string, level LogLevel, writers ...LogWriter) *Worker

func (*Worker) SetTimeFormat

func (wrk *Worker) SetTimeFormat(format string)

available formats: Y,M,D,h,m,s,x. these format will be replaced by 'd' and used normaly with fmt.Sprintf

func (*Worker) ShowCaller

func (wrk *Worker) ShowCaller(show bool)

func (*Worker) ShowLevel

func (wrk *Worker) ShowLevel(show bool)

type Wrap

type Wrap struct {
	Logger ILogger
	Tag    string
}

func (Wrap) CallerAt

func (this Wrap) CallerAt(depth int) ILogger

func (Wrap) Debugf

func (this Wrap) Debugf(format string, what ...interface{})

func (Wrap) Errorf

func (this Wrap) Errorf(format string, what ...interface{})

func (Wrap) Fatalf

func (this Wrap) Fatalf(format string, what ...interface{})

func (Wrap) Infof

func (this Wrap) Infof(format string, what ...interface{})

func (Wrap) IsActive

func (this Wrap) IsActive(level LogLevel) bool

func (Wrap) Tracef

func (this Wrap) Tracef(format string, what ...interface{})

func (Wrap) Warnf

func (this Wrap) Warnf(format string, what ...interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL