[MM-58113] Remove deprecated AdvancedLoggingConfig (#27386)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1c68aa2dbf
Коммит
6229b784eb
@@ -122,7 +122,7 @@ func GetLogSettingsFromNotificationsLogSettings(notificationLogSettings *model.N
|
||||
settings.FileJson = notificationLogSettings.FileJson
|
||||
settings.FileLevel = notificationLogSettings.FileLevel
|
||||
settings.FileLocation = notificationLogSettings.FileLocation
|
||||
settings.AdvancedLoggingConfig = notificationLogSettings.AdvancedLoggingConfig
|
||||
settings.AdvancedLoggingJSON = notificationLogSettings.AdvancedLoggingJSON
|
||||
settings.EnableColor = notificationLogSettings.EnableColor
|
||||
return settings
|
||||
}
|
||||
|
||||
@@ -552,18 +552,16 @@ func (ts *TelemetryService) trackConfig() {
|
||||
"enable_webhook_debugging": cfg.LogSettings.EnableWebhookDebugging,
|
||||
"isdefault_file_location": isDefault(cfg.LogSettings.FileLocation, ""),
|
||||
"advanced_logging_json": len(cfg.LogSettings.AdvancedLoggingJSON) != 0,
|
||||
"advanced_logging_config": cfg.LogSettings.AdvancedLoggingConfig != nil && *cfg.LogSettings.AdvancedLoggingConfig != "",
|
||||
})
|
||||
|
||||
ts.SendTelemetry(TrackConfigAudit, map[string]any{
|
||||
"file_enabled": *cfg.ExperimentalAuditSettings.FileEnabled,
|
||||
"file_max_size_mb": *cfg.ExperimentalAuditSettings.FileMaxSizeMB,
|
||||
"file_max_age_days": *cfg.ExperimentalAuditSettings.FileMaxAgeDays,
|
||||
"file_max_backups": *cfg.ExperimentalAuditSettings.FileMaxBackups,
|
||||
"file_compress": *cfg.ExperimentalAuditSettings.FileCompress,
|
||||
"file_max_queue_size": *cfg.ExperimentalAuditSettings.FileMaxQueueSize,
|
||||
"advanced_logging_json": len(cfg.ExperimentalAuditSettings.AdvancedLoggingJSON) != 0,
|
||||
"advanced_logging_config": cfg.ExperimentalAuditSettings.AdvancedLoggingConfig != nil && *cfg.ExperimentalAuditSettings.AdvancedLoggingConfig != "",
|
||||
"file_enabled": *cfg.ExperimentalAuditSettings.FileEnabled,
|
||||
"file_max_size_mb": *cfg.ExperimentalAuditSettings.FileMaxSizeMB,
|
||||
"file_max_age_days": *cfg.ExperimentalAuditSettings.FileMaxAgeDays,
|
||||
"file_max_backups": *cfg.ExperimentalAuditSettings.FileMaxBackups,
|
||||
"file_compress": *cfg.ExperimentalAuditSettings.FileCompress,
|
||||
"file_max_queue_size": *cfg.ExperimentalAuditSettings.FileMaxQueueSize,
|
||||
"advanced_logging_json": len(cfg.ExperimentalAuditSettings.AdvancedLoggingJSON) != 0,
|
||||
})
|
||||
|
||||
ts.SendTelemetry(TrackConfigNotificationLog, map[string]any{
|
||||
@@ -575,7 +573,6 @@ func (ts *TelemetryService) trackConfig() {
|
||||
"file_json": *cfg.NotificationLogSettings.FileJson,
|
||||
"isdefault_file_location": isDefault(*cfg.NotificationLogSettings.FileLocation, ""),
|
||||
"advanced_logging_json": len(cfg.NotificationLogSettings.AdvancedLoggingJSON) != 0,
|
||||
"advanced_logging_config": cfg.NotificationLogSettings.AdvancedLoggingConfig != nil && *cfg.NotificationLogSettings.AdvancedLoggingConfig != "",
|
||||
})
|
||||
|
||||
ts.SendTelemetry(TrackConfigPassword, map[string]any{
|
||||
|
||||
@@ -1357,7 +1357,6 @@ type LogSettings struct {
|
||||
VerboseDiagnostics *bool `access:"environment_logging,write_restrictable,cloud_restrictable"` // telemetry: none
|
||||
EnableSentry *bool `access:"environment_logging,write_restrictable,cloud_restrictable"` // telemetry: none
|
||||
AdvancedLoggingJSON json.RawMessage `access:"environment_logging,write_restrictable,cloud_restrictable"`
|
||||
AdvancedLoggingConfig *string `access:"environment_logging,write_restrictable,cloud_restrictable"` // Deprecated: use `AdvancedLoggingJSON`
|
||||
MaxFieldSize *int `access:"environment_logging,write_restrictable,cloud_restrictable"`
|
||||
}
|
||||
|
||||
@@ -1435,37 +1434,29 @@ func (s *LogSettings) SetDefaults() {
|
||||
s.AdvancedLoggingJSON = []byte("{}")
|
||||
}
|
||||
|
||||
if s.AdvancedLoggingConfig == nil {
|
||||
s.AdvancedLoggingConfig = NewPointer("")
|
||||
}
|
||||
|
||||
if s.MaxFieldSize == nil {
|
||||
s.MaxFieldSize = NewPointer(2048)
|
||||
}
|
||||
}
|
||||
|
||||
// GetAdvancedLoggingConfig returns the advanced logging config as a []byte.
|
||||
// AdvancedLoggingJSON takes precedence over the deprecated AdvancedLoggingConfig.
|
||||
func (s *LogSettings) GetAdvancedLoggingConfig() []byte {
|
||||
if !utils.IsEmptyJSON(s.AdvancedLoggingJSON) {
|
||||
return s.AdvancedLoggingJSON
|
||||
}
|
||||
if s.AdvancedLoggingConfig != nil && !utils.IsEmptyJSON([]byte(*s.AdvancedLoggingConfig)) {
|
||||
return []byte(*s.AdvancedLoggingConfig)
|
||||
}
|
||||
|
||||
return []byte("{}")
|
||||
}
|
||||
|
||||
type ExperimentalAuditSettings struct {
|
||||
FileEnabled *bool `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
||||
FileName *string `access:"experimental_features,write_restrictable,cloud_restrictable"` // telemetry: none
|
||||
FileMaxSizeMB *int `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
||||
FileMaxAgeDays *int `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
||||
FileMaxBackups *int `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
||||
FileCompress *bool `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
||||
FileMaxQueueSize *int `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
||||
AdvancedLoggingJSON json.RawMessage `access:"experimental_features,write_restrictable"`
|
||||
AdvancedLoggingConfig *string `access:"experimental_features,write_restrictable,cloud_restrictable"` // Deprecated: use `AdvancedLoggingJSON`
|
||||
FileEnabled *bool `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
||||
FileName *string `access:"experimental_features,write_restrictable,cloud_restrictable"` // telemetry: none
|
||||
FileMaxSizeMB *int `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
||||
FileMaxAgeDays *int `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
||||
FileMaxBackups *int `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
||||
FileCompress *bool `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
||||
FileMaxQueueSize *int `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
||||
AdvancedLoggingJSON json.RawMessage `access:"experimental_features,write_restrictable"`
|
||||
}
|
||||
|
||||
func (s *ExperimentalAuditSettings) SetDefaults() {
|
||||
@@ -1500,35 +1491,27 @@ func (s *ExperimentalAuditSettings) SetDefaults() {
|
||||
if utils.IsEmptyJSON(s.AdvancedLoggingJSON) {
|
||||
s.AdvancedLoggingJSON = []byte("{}")
|
||||
}
|
||||
|
||||
if s.AdvancedLoggingConfig == nil {
|
||||
s.AdvancedLoggingConfig = NewPointer("")
|
||||
}
|
||||
}
|
||||
|
||||
// GetAdvancedLoggingConfig returns the advanced logging config as a []byte.
|
||||
// AdvancedLoggingJSON takes precedence over the deprecated AdvancedLoggingConfig.
|
||||
func (s *ExperimentalAuditSettings) GetAdvancedLoggingConfig() []byte {
|
||||
if !utils.IsEmptyJSON(s.AdvancedLoggingJSON) {
|
||||
return s.AdvancedLoggingJSON
|
||||
}
|
||||
if s.AdvancedLoggingConfig != nil && !utils.IsEmptyJSON([]byte(*s.AdvancedLoggingConfig)) {
|
||||
return []byte(*s.AdvancedLoggingConfig)
|
||||
}
|
||||
|
||||
return []byte("{}")
|
||||
}
|
||||
|
||||
type NotificationLogSettings struct {
|
||||
EnableConsole *bool `access:"write_restrictable,cloud_restrictable"`
|
||||
ConsoleLevel *string `access:"write_restrictable,cloud_restrictable"`
|
||||
ConsoleJson *bool `access:"write_restrictable,cloud_restrictable"`
|
||||
EnableColor *bool `access:"write_restrictable,cloud_restrictable"` // telemetry: none
|
||||
EnableFile *bool `access:"write_restrictable,cloud_restrictable"`
|
||||
FileLevel *string `access:"write_restrictable,cloud_restrictable"`
|
||||
FileJson *bool `access:"write_restrictable,cloud_restrictable"`
|
||||
FileLocation *string `access:"write_restrictable,cloud_restrictable"`
|
||||
AdvancedLoggingJSON json.RawMessage `access:"write_restrictable,cloud_restrictable"`
|
||||
AdvancedLoggingConfig *string `access:"write_restrictable,cloud_restrictable"` // Deprecated: use `AdvancedLoggingJSON`
|
||||
EnableConsole *bool `access:"write_restrictable,cloud_restrictable"`
|
||||
ConsoleLevel *string `access:"write_restrictable,cloud_restrictable"`
|
||||
ConsoleJson *bool `access:"write_restrictable,cloud_restrictable"`
|
||||
EnableColor *bool `access:"write_restrictable,cloud_restrictable"` // telemetry: none
|
||||
EnableFile *bool `access:"write_restrictable,cloud_restrictable"`
|
||||
FileLevel *string `access:"write_restrictable,cloud_restrictable"`
|
||||
FileJson *bool `access:"write_restrictable,cloud_restrictable"`
|
||||
FileLocation *string `access:"write_restrictable,cloud_restrictable"`
|
||||
AdvancedLoggingJSON json.RawMessage `access:"write_restrictable,cloud_restrictable"`
|
||||
}
|
||||
|
||||
func (s *NotificationLogSettings) SetDefaults() {
|
||||
@@ -1567,21 +1550,14 @@ func (s *NotificationLogSettings) SetDefaults() {
|
||||
if utils.IsEmptyJSON(s.AdvancedLoggingJSON) {
|
||||
s.AdvancedLoggingJSON = []byte("{}")
|
||||
}
|
||||
|
||||
if s.AdvancedLoggingConfig == nil {
|
||||
s.AdvancedLoggingConfig = NewPointer("")
|
||||
}
|
||||
}
|
||||
|
||||
// GetAdvancedLoggingConfig returns the advanced logging config as a []byte.
|
||||
// AdvancedLoggingJSON takes precedence over the deprecated AdvancedLoggingConfig.
|
||||
func (s *NotificationLogSettings) GetAdvancedLoggingConfig() []byte {
|
||||
if !utils.IsEmptyJSON(s.AdvancedLoggingJSON) {
|
||||
return s.AdvancedLoggingJSON
|
||||
}
|
||||
if s.AdvancedLoggingConfig != nil && !utils.IsEmptyJSON([]byte(*s.AdvancedLoggingConfig)) {
|
||||
return []byte(*s.AdvancedLoggingConfig)
|
||||
}
|
||||
|
||||
return []byte("{}")
|
||||
}
|
||||
|
||||
|
||||
@@ -1356,12 +1356,6 @@ func TestLogSettingsIsValid(t *testing.T) {
|
||||
},
|
||||
ExpectError: false,
|
||||
},
|
||||
"AdvancedLoggingConfig contains filepath": {
|
||||
LogSettings: LogSettings{
|
||||
AdvancedLoggingConfig: sToP("/some/Path"),
|
||||
},
|
||||
ExpectError: false,
|
||||
},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
test.LogSettings.SetDefaults()
|
||||
|
||||
Ссылка в новой задаче
Block a user