log

package
v0.9.71 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TRACE = iota
	DEBUG
	INFO
	WARN
	ERROR
	CRITICAL
	FATAL
)

Variables

This section is empty.

Functions

func Close added in v0.5.5

func Close()

func Critical

func Critical(skip int, format string, v ...interface{})

func Debug

func Debug(format string, v ...interface{})

func Error

func Error(skip int, format string, v ...interface{})

func Fatal added in v0.4.0

func Fatal(skip int, format string, v ...interface{})

func Info

func Info(format string, v ...interface{})

func NewGitLogger added in v0.5.0

func NewGitLogger(logPath string)

FIXME: use same log level as other loggers.

func NewLogger

func NewLogger(bufLen int64, mode, config string)

func Register added in v0.5.0

func Register(name string, log loggerType)

Register registers given logger provider to adapters.

func Trace

func Trace(format string, v ...interface{})

func Warn

func Warn(format string, v ...interface{})

Types

type Brush added in v0.5.0

type Brush func(string) string

func NewBrush added in v0.5.0

func NewBrush(color string) Brush

type ConnWriter added in v0.5.0

type ConnWriter struct {
	ReconnectOnMsg bool   `json:"reconnectOnMsg"`
	Reconnect      bool   `json:"reconnect"`
	Net            string `json:"net"`
	Addr           string `json:"addr"`
	Level          int    `json:"level"`
	// contains filtered or unexported fields
}

ConnWriter implements LoggerInterface. it writes messages in keep-live tcp connection.

func (*ConnWriter) Destroy added in v0.5.0

func (cw *ConnWriter) Destroy()

destroy connection writer and close tcp listener.

func (*ConnWriter) Flush added in v0.5.0

func (_ *ConnWriter) Flush()

func (*ConnWriter) Init added in v0.5.0

func (cw *ConnWriter) Init(jsonconfig string) error

init connection writer with json config. json config only need key "level".

func (*ConnWriter) WriteMsg added in v0.5.0

func (cw *ConnWriter) WriteMsg(msg string, skip, level int) error

write message in connection. if connection is down, try to re-connect.

type ConsoleWriter added in v0.5.0

type ConsoleWriter struct {
	Level int `json:"level"`
	// contains filtered or unexported fields
}

ConsoleWriter implements LoggerInterface and writes messages to terminal.

func (*ConsoleWriter) Destroy added in v0.5.0

func (_ *ConsoleWriter) Destroy()

func (*ConsoleWriter) Flush added in v0.5.0

func (_ *ConsoleWriter) Flush()

func (*ConsoleWriter) Init added in v0.5.0

func (cw *ConsoleWriter) Init(config string) error

func (*ConsoleWriter) WriteMsg added in v0.5.0

func (cw *ConsoleWriter) WriteMsg(msg string, skip, level int) error

type FileLogWriter added in v0.5.0

type FileLogWriter struct {
	*log.Logger

	// The opened file
	Filename string `json:"filename"`

	Maxlines int `json:"maxlines"`

	// Rotate at size
	Maxsize int `json:"maxsize"`

	// Rotate daily
	Daily   bool  `json:"daily"`
	Maxdays int64 `json:"maxdays"`

	Rotate bool `json:"rotate"`

	Level int `json:"level"`
	// contains filtered or unexported fields
}

FileLogWriter implements LoggerInterface. It writes messages by lines limit, file size limit, or time frequency.

func (*FileLogWriter) Destroy added in v0.5.0

func (w *FileLogWriter) Destroy()

destroy file logger, close file writer.

func (*FileLogWriter) DoRotate added in v0.5.0

func (w *FileLogWriter) DoRotate() error

DoRotate means it need to write file in new file. new file name like xx.log.2013-01-01.2

func (*FileLogWriter) Flush added in v0.5.0

func (w *FileLogWriter) Flush()

flush file logger. there are no buffering messages in file logger in memory. flush file means sync file from disk.

func (*FileLogWriter) Init added in v0.5.0

func (w *FileLogWriter) Init(config string) error

Init file logger with json config. config like:

{
"filename":"log/gogs.log",
"maxlines":10000,
"maxsize":1<<30,
"daily":true,
"maxdays":15,
"rotate":true
}

func (*FileLogWriter) StartLogger added in v0.5.0

func (w *FileLogWriter) StartLogger() error

start file logger. create log file and set to locker-inside file writer.

func (*FileLogWriter) WriteMsg added in v0.5.0

func (w *FileLogWriter) WriteMsg(msg string, skip, level int) error

write logger message into file.

type LogLevel added in v0.5.0

type LogLevel int

type Logger added in v0.5.0

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

Logger is default logger in beego application. it can contain several providers and log message into all providers.

var (
	GitLogger *Logger
)

func (*Logger) Close added in v0.5.0

func (l *Logger) Close()

Close closes logger, flush all chan data and destroy all adapter instances.

func (*Logger) Critical added in v0.5.0

func (l *Logger) Critical(skip int, format string, v ...interface{})

func (*Logger) Debug added in v0.5.0

func (l *Logger) Debug(format string, v ...interface{})

func (*Logger) DelLogger added in v0.5.0

func (l *Logger) DelLogger(adapter string) error

DelLogger removes a logger adapter instance.

func (*Logger) Error added in v0.5.0

func (l *Logger) Error(skip int, format string, v ...interface{})

func (*Logger) Fatal added in v0.5.0

func (l *Logger) Fatal(skip int, format string, v ...interface{})

func (*Logger) Flush added in v0.5.0

func (l *Logger) Flush()

Flush flushs all chan data.

func (*Logger) Info added in v0.5.0

func (l *Logger) Info(format string, v ...interface{})

func (*Logger) SetLogger added in v0.5.0

func (l *Logger) SetLogger(adapter string, config string) error

SetLogger sets new logger instance with given logger adapter and config.

func (*Logger) StartLogger added in v0.5.0

func (l *Logger) StartLogger()

StartLogger starts logger chan reading.

func (*Logger) Trace added in v0.5.0

func (l *Logger) Trace(format string, v ...interface{})

func (*Logger) Warn added in v0.5.0

func (l *Logger) Warn(format string, v ...interface{})

type LoggerInterface added in v0.5.0

type LoggerInterface interface {
	Init(config string) error
	WriteMsg(msg string, skip, level int) error
	Destroy()
	Flush()
}

LoggerInterface represents behaviors of a logger provider.

func NewConn added in v0.5.0

func NewConn() LoggerInterface

create new ConnWrite returning as LoggerInterface.

func NewConsole added in v0.5.0

func NewConsole() LoggerInterface

create ConsoleWriter returning as LoggerInterface.

func NewFileWriter added in v0.5.0

func NewFileWriter() LoggerInterface

create a FileLogWriter returning as LoggerInterface.

func NewSmtpWriter added in v0.5.0

func NewSmtpWriter() LoggerInterface

create smtp writer.

type MuxWriter added in v0.5.0

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

an *os.File writer with locker.

func (*MuxWriter) SetFd added in v0.5.0

func (l *MuxWriter) SetFd(fd *os.File)

set os.File in writer.

func (*MuxWriter) Write added in v0.5.0

func (l *MuxWriter) Write(b []byte) (int, error)

write to os.File.

type SmtpWriter added in v0.5.0

type SmtpWriter struct {
	Username           string   `json:"Username"`
	Password           string   `json:"password"`
	Host               string   `json:"Host"`
	Subject            string   `json:"subject"`
	RecipientAddresses []string `json:"sendTos"`
	Level              int      `json:"level"`
}

smtpWriter implements LoggerInterface and is used to send emails via given SMTP-server.

func (*SmtpWriter) Destroy added in v0.5.0

func (_ *SmtpWriter) Destroy()

func (*SmtpWriter) Flush added in v0.5.0

func (_ *SmtpWriter) Flush()

func (*SmtpWriter) Init added in v0.5.0

func (sw *SmtpWriter) Init(jsonconfig string) error

init smtp writer with json config. config like:

{
	"Username":"example@gmail.com",
	"password:"password",
	"host":"smtp.gmail.com:465",
	"subject":"email title",
	"sendTos":["email1","email2"],
	"level":LevelError
}

func (*SmtpWriter) WriteMsg added in v0.5.0

func (s *SmtpWriter) WriteMsg(msg string, skip, level int) error

write message in smtp writer. it will send an email with subject and only this message.

Jump to

Keyboard shortcuts

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