logger

package
v0.0.0-...-b8a1a0e Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOG_ROTATION_INTERVAL = 24 * time.Hour       // every day
	LOG_MAX_AGE           = 365 * 24 * time.Hour // every year
	LOG_FORMAT            = "%{time:2006-01-02 15:04:05.000} [%{level:.4s}] [%{module}] %{shortfile} %{message}"
	LOG_COLOR_FORMAT      = "%{color}%{time:2006-01-02 15:04:05.000} [%{level:.4s}]%{color:reset} [%{module}] %{shortfile} %{message}"
	SYSLOG_FORMAT         = "[%{level:.4s}] %{shortfile} %{message}"
)
View Source
const (
	SYSLOG_PRIORITY = syslog.LOG_CRIT | syslog.LOG_DAEMON
)

Variables

This section is empty.

Functions

func EnableCustomBackends

func EnableCustomBackends(backends ...ClosableBackend)

func EnableFileLog

func EnableFileLog(logPath string) error

func EnableFileLogWithMaxAge

func EnableFileLogWithMaxAge(logPath string, maxAge time.Duration) error

func EnableRsyslog

func EnableRsyslog(msgType byte, remotePort int, remotes ...string) error

msgType在datatype/droplet-message.go中定义 trident调用时前2个参数传入datatype.MESSAGE_TYPE_SYSLOG 和 30033

func EnableStdoutLog

func EnableStdoutLog()

func EnableSyslog

func EnableSyslog() error

func GinLogFormat

func GinLogFormat(param gin.LogFormatterParams) string

func RsyslogSetHostname

func RsyslogSetHostname(value string)

func RsyslogSetThreshold

func RsyslogSetThreshold(value uint32)

Types

type ClosableBackend

type ClosableBackend interface {
	logging.Backend
	io.Closer
}

type PrefixLogger

type PrefixLogger struct {
	*logging.Logger
	// contains filtered or unexported fields
}

func GetPrefixLogger

func GetPrefixLogger(module, prefix string) (*PrefixLogger, error)

func WrapWithPrefixLogger

func WrapWithPrefixLogger(prefix string, logger *logging.Logger) *PrefixLogger

将logger包装为前缀logger 注意需要自行将ExtraCalldepth加1,以便拿到log文件名,行号等信息

func (*PrefixLogger) Critical

func (l *PrefixLogger) Critical(args ...interface{})

func (*PrefixLogger) Criticalf

func (l *PrefixLogger) Criticalf(format string, args ...interface{})

func (*PrefixLogger) Debug

func (l *PrefixLogger) Debug(args ...interface{})

func (*PrefixLogger) Debugf

func (l *PrefixLogger) Debugf(format string, args ...interface{})

func (*PrefixLogger) Error

func (l *PrefixLogger) Error(args ...interface{})

func (*PrefixLogger) Errorf

func (l *PrefixLogger) Errorf(format string, args ...interface{})

func (*PrefixLogger) Fatal

func (l *PrefixLogger) Fatal(args ...interface{})

func (*PrefixLogger) Fatalf

func (l *PrefixLogger) Fatalf(format string, args ...interface{})

func (*PrefixLogger) GetPrefix

func (l *PrefixLogger) GetPrefix() string

func (*PrefixLogger) Info

func (l *PrefixLogger) Info(args ...interface{})

func (*PrefixLogger) Infof

func (l *PrefixLogger) Infof(format string, args ...interface{})

func (*PrefixLogger) Notice

func (l *PrefixLogger) Notice(args ...interface{})

func (*PrefixLogger) Noticef

func (l *PrefixLogger) Noticef(format string, args ...interface{})

func (*PrefixLogger) Panic

func (l *PrefixLogger) Panic(args ...interface{})

func (*PrefixLogger) Panicf

func (l *PrefixLogger) Panicf(format string, args ...interface{})

func (*PrefixLogger) UpdatePrefix

func (l *PrefixLogger) UpdatePrefix(prefix string)

func (*PrefixLogger) Warning

func (l *PrefixLogger) Warning(args ...interface{})

func (*PrefixLogger) Warningf

func (l *PrefixLogger) Warningf(format string, args ...interface{})

type RSyslogWriter

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

func NewRsyslogWriter

func NewRsyslogWriter(network, raddr string, tag, header string) *RSyslogWriter

func (*RSyslogWriter) Close

func (w *RSyslogWriter) Close() error

Close closes a connection to the syslog daemon.

func (*RSyslogWriter) SetHostname

func (w *RSyslogWriter) SetHostname(value string)

func (*RSyslogWriter) SetThreshold

func (w *RSyslogWriter) SetThreshold(value uint32)

func (*RSyslogWriter) Write

func (w *RSyslogWriter) Write(b []byte) (int, error)

Write sends a log message to the syslog daemon.

Jump to

Keyboard shortcuts

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