This is an automated email from the ASF dual-hosted git repository. elsloo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push: new cb671df Fix TO CRconfig changelog cb671df is described below commit cb671dfd3dc0fc5db47acd55726419badde6d6d5 Author: Robert Butts <r...@apache.org> AuthorDate: Wed May 16 15:24:10 2018 -0600 Fix TO CRconfig changelog --- traffic_ops/traffic_ops_golang/api/change_log.go | 9 +++++++++ traffic_ops/traffic_ops_golang/crconfig/handler.go | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/traffic_ops/traffic_ops_golang/api/change_log.go b/traffic_ops/traffic_ops_golang/api/change_log.go index 17c54a7..f2fb18f 100644 --- a/traffic_ops/traffic_ops_golang/api/change_log.go +++ b/traffic_ops/traffic_ops_golang/api/change_log.go @@ -20,11 +20,13 @@ package api */ import ( + "database/sql" "fmt" "github.com/apache/incubator-trafficcontrol/lib/go-log" "github.com/apache/incubator-trafficcontrol/lib/go-tc" "github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/auth" + "github.com/jmoiron/sqlx" ) @@ -76,3 +78,10 @@ func CreateChangeLog(level string, action string, i Identifier, user auth.Curren } return nil } + +func CreateChangeLogRaw(level string, message string, user auth.CurrentUser, db *sql.DB) error { + if _, err := db.Exec(`INSERT INTO log (level, message, tm_user) VALUES ($1, $2, $3)`, level, message, user.ID); err != nil { + return fmt.Errorf("inserting change log level '%v' message '%v' user '%v': %v", level, message, user.ID, err) + } + return nil +} diff --git a/traffic_ops/traffic_ops_golang/crconfig/handler.go b/traffic_ops/traffic_ops_golang/crconfig/handler.go index 0c4453c..6822b60 100644 --- a/traffic_ops/traffic_ops_golang/crconfig/handler.go +++ b/traffic_ops/traffic_ops_golang/crconfig/handler.go @@ -189,9 +189,13 @@ func SnapshotHandler(db *sqlx.DB, cfg config.Config) http.HandlerFunc { } if err := Snapshot(db.DB, crConfig); err != nil { + log.Errorln(r.RemoteAddr + " snaphsotting CRConfig: " + err.Error()) handleErrs(http.StatusInternalServerError, err) return } + if err := api.CreateChangeLogRaw(api.ApiChange, "Snapshot of CRConfig performed for "+cdn, *user, db.DB); err != nil { + log.Errorln("creating CRConfig snapshot changelog: " + err.Error()) + } w.WriteHeader(http.StatusOK) // TODO change to 204 No Content in new version } } @@ -236,7 +240,9 @@ func SnapshotOldGUIHandler(db *sqlx.DB, cfg config.Config) http.HandlerFunc { writePerlHTMLErr(w, r, err) return } - + if err := api.CreateChangeLogRaw(api.ApiChange, "Snapshot of CRConfig performed for "+cdn, *user, db.DB); err != nil { + log.Errorln("creating CRConfig snapshot changelog: " + err.Error()) + } http.Redirect(w, r, "/tools/flash_and_close/"+url.PathEscape("Successfully wrote the CRConfig.json!"), http.StatusFound) } } -- To stop receiving notification emails like this one, please contact els...@apache.org.