MM-27493 Shared channels (MVP) (#17301)
Remote Cluster Service - provides ability for multiple Mattermost cluster instances to create a trusted connection with each other and exchange messages - trusted connections are managed via slash commands (for now) - facilitates features requiring inter-cluster communication, such as Shared Channels Shared Channels Service - provides ability to shared channels between one or more Mattermost cluster instances (using trusted connection) - sharing/unsharing of channels is managed via slash commands (for now)
Этот коммит содержится в:
@@ -33,6 +33,10 @@ func defaultLog(level, msg string, fields ...Field) {
|
||||
}
|
||||
}
|
||||
|
||||
func defaultIsLevelEnabled(level LogLevel) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func defaultDebugLog(msg string, fields ...Field) {
|
||||
defaultLog("debug", msg, fields...)
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ func InitGlobalLogger(logger *Logger) {
|
||||
glob := *logger
|
||||
glob.zap = glob.zap.WithOptions(zap.AddCallerSkip(1))
|
||||
globalLogger = &glob
|
||||
IsLevelEnabled = globalLogger.IsLevelEnabled
|
||||
Debug = globalLogger.Debug
|
||||
Info = globalLogger.Info
|
||||
Warn = globalLogger.Warn
|
||||
@@ -59,6 +60,7 @@ func RedirectStdLog(logger *Logger) {
|
||||
log.SetOutput(logWriterFunc(writer))
|
||||
}
|
||||
|
||||
type IsLevelEnabledFunc func(LogLevel) bool
|
||||
type LogFunc func(string, ...Field)
|
||||
type LogFuncCustom func(LogLevel, string, ...Field)
|
||||
type LogFuncCustomMulti func([]LogLevel, string, ...Field)
|
||||
@@ -79,6 +81,7 @@ func GloballyEnableDebugLogForTest() {
|
||||
globalLogger.consoleLevel.SetLevel(zapcore.DebugLevel)
|
||||
}
|
||||
|
||||
var IsLevelEnabled IsLevelEnabledFunc = defaultIsLevelEnabled
|
||||
var Debug LogFunc = defaultDebugLog
|
||||
var Info LogFunc = defaultInfoLog
|
||||
var Warn LogFunc = defaultWarnLog
|
||||
|
||||
@@ -30,6 +30,18 @@ var (
|
||||
// used by the TCP log target
|
||||
LvlTcpLogTarget = LogLevel{ID: 120, Name: "TcpLogTarget"}
|
||||
|
||||
// used by Remote Cluster Service
|
||||
LvlRemoteClusterServiceDebug = LogLevel{ID: 130, Name: "RemoteClusterServiceDebug"}
|
||||
LvlRemoteClusterServiceError = LogLevel{ID: 131, Name: "RemoteClusterServiceError"}
|
||||
LvlRemoteClusterServiceWarn = LogLevel{ID: 132, Name: "RemoteClusterServiceWarn"}
|
||||
|
||||
// used by Shared Channel Sync Service
|
||||
LvlSharedChannelServiceDebug = LogLevel{ID: 200, Name: "SharedChannelServiceDebug"}
|
||||
LvlSharedChannelServiceError = LogLevel{ID: 201, Name: "SharedChannelServiceError"}
|
||||
LvlSharedChannelServiceWarn = LogLevel{ID: 202, Name: "SharedChannelServiceWarn"}
|
||||
LvlSharedChannelServiceMessagesInbound = LogLevel{ID: 203, Name: "SharedChannelServiceMsgInbound"}
|
||||
LvlSharedChannelServiceMessagesOutbound = LogLevel{ID: 204, Name: "SharedChannelServiceMsgOutbound"}
|
||||
|
||||
// add more here ...
|
||||
)
|
||||
|
||||
|
||||
@@ -57,6 +57,17 @@ var NamedErr = zap.NamedError
|
||||
var Bool = zap.Bool
|
||||
var Duration = zap.Duration
|
||||
|
||||
type LoggerIFace interface {
|
||||
IsLevelEnabled(LogLevel) bool
|
||||
Debug(string, ...Field)
|
||||
Info(string, ...Field)
|
||||
Warn(string, ...Field)
|
||||
Error(string, ...Field)
|
||||
Critical(string, ...Field)
|
||||
Log(LogLevel, string, ...Field)
|
||||
LogM([]LogLevel, string, ...Field)
|
||||
}
|
||||
|
||||
type TargetInfo logr.TargetInfo
|
||||
|
||||
type LoggerConfiguration struct {
|
||||
@@ -207,6 +218,10 @@ func (l *Logger) Sugar() *SugarLogger {
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Logger) IsLevelEnabled(level LogLevel) bool {
|
||||
return isLevelEnabled(l.getLogger(), logr.Level(level))
|
||||
}
|
||||
|
||||
func (l *Logger) Debug(message string, fields ...Field) {
|
||||
l.zap.Debug(message, fields...)
|
||||
if isLevelEnabled(l.getLogger(), logr.Debug) {
|
||||
|
||||
Ссылка в новой задаче
Block a user