Documentation ¶
Index ¶
- Constants
- func EnableCustomBackends(backends ...ClosableBackend)
- func EnableFileLog(logPath string) error
- func EnableFileLogWithMaxAge(logPath string, maxAge time.Duration) error
- func EnableRsyslog(msgType byte, remotePort int, remotes ...string) error
- func EnableStdoutLog()
- func EnableSyslog() error
- func GinLogFormat(param gin.LogFormatterParams) string
- func RsyslogSetHostname(value string)
- func RsyslogSetThreshold(value uint32)
- type ClosableBackend
- type Logger
- func (l *Logger) Critical(args ...interface{})
- func (l *Logger) Criticalf(format string, args ...interface{})
- func (l *Logger) Debug(args ...interface{})
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Fatal(args ...interface{})
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Info(args ...interface{})
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) Notice(args ...interface{})
- func (l *Logger) Noticef(format string, args ...interface{})
- func (l *Logger) Panic(args ...interface{})
- func (l *Logger) Panicf(format string, args ...interface{})
- func (l *Logger) Warning(args ...interface{})
- func (l *Logger) Warningf(format string, args ...interface{})
- type ORGPrefix
- type Prefix
- type PrefixLogger
- func (l *PrefixLogger) Critical(args ...interface{})
- func (l *PrefixLogger) Criticalf(format string, args ...interface{})
- func (l *PrefixLogger) Debug(args ...interface{})
- func (l *PrefixLogger) Debugf(format string, args ...interface{})
- func (l *PrefixLogger) Error(args ...interface{})
- func (l *PrefixLogger) Errorf(format string, args ...interface{})
- func (l *PrefixLogger) Fatal(args ...interface{})
- func (l *PrefixLogger) Fatalf(format string, args ...interface{})
- func (l *PrefixLogger) GetPrefix() string
- func (l *PrefixLogger) Info(args ...interface{})
- func (l *PrefixLogger) Infof(format string, args ...interface{})
- func (l *PrefixLogger) Notice(args ...interface{})
- func (l *PrefixLogger) Noticef(format string, args ...interface{})
- func (l *PrefixLogger) Panic(args ...interface{})
- func (l *PrefixLogger) Panicf(format string, args ...interface{})
- func (l *PrefixLogger) UpdatePrefix(prefix string)
- func (l *PrefixLogger) Warning(args ...interface{})
- func (l *PrefixLogger) Warningf(format string, args ...interface{})
- type RSyslogWriter
- type TeamPrefix
Constants ¶
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}" )
const (
SYSLOG_PRIORITY = syslog.LOG_CRIT | syslog.LOG_DAEMON
)
Variables ¶
This section is empty.
Functions ¶
func EnableCustomBackends ¶
func EnableCustomBackends(backends ...ClosableBackend)
func EnableFileLog ¶
func EnableFileLogWithMaxAge ¶
func EnableRsyslog ¶
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 Logger ¶
Logger is a wrapper around go-logging.Logger. It adds support for logging with flexible prefixes. Prefixes should implement the Prefix interface. The Logger will automatically extract the prefixes from the arguments and prepend them to the log message ordered by the order of the arguments. Prefixes must be placed at the end of the arguments list. Example:
// logger is a *Logger, ORGPrefix is the struct which implements Prefix interface and returns the organization ID information. logger.Info("message", ORGPrefix(2)) will log: "[ORGID-2] message"
func MustGetLogger ¶
type ORGPrefix ¶
type ORGPrefix int
ORGPrefix implements LogPrefix to provide a prefix for log messages with an organization ID.
type Prefix ¶
type Prefix interface { // Prefix returns the prefix string. Prefix() string }
Prefix is an interface that can be implemented by types that want to provide a prefix to a log message.
func NewORGPrefix ¶
func NewTeamPrefix ¶
type PrefixLogger ¶
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)
type TeamPrefix ¶
type TeamPrefix int
func (TeamPrefix) Prefix ¶
func (t TeamPrefix) Prefix() string