diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-27 22:33:57 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-27 22:33:57 +0300 |
| commit | 87113c5fb4c539573a33114581debddecfc9ece9 (patch) | |
| tree | 5c02f05744b85c4218924fb802dcfae745c7a67d /backend/handlers/logs.go | |
| parent | feat: check for deleted records in users (#56) (diff) | |
| download | lphub-87113c5fb4c539573a33114581debddecfc9ece9.tar.gz lphub-87113c5fb4c539573a33114581debddecfc9ece9.tar.bz2 lphub-87113c5fb4c539573a33114581debddecfc9ece9.zip | |
feat: detailed logging, db changes (#55)
Former-commit-id: 74219281915f55ac46cff3795edd4364be84d561
Diffstat (limited to 'backend/handlers/logs.go')
| -rw-r--r-- | backend/handlers/logs.go | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/backend/handlers/logs.go b/backend/handlers/logs.go index 4c7b415..d0561bd 100644 --- a/backend/handlers/logs.go +++ b/backend/handlers/logs.go | |||
| @@ -25,10 +25,13 @@ const ( | |||
| 25 | LogDescriptionUserUpdateCountrySuccess string = "UpdateCountrySuccess" | 25 | LogDescriptionUserUpdateCountrySuccess string = "UpdateCountrySuccess" |
| 26 | LogDescriptionUserUpdateCountryFail string = "UpdateCountryFail" | 26 | LogDescriptionUserUpdateCountryFail string = "UpdateCountryFail" |
| 27 | 27 | ||
| 28 | LogDescriptionMapSummaryCreate string = "MapSummaryCreate" | 28 | LogDescriptionMapSummaryCreateSuccess string = "MapSummaryCreateSuccess" |
| 29 | LogDescriptionMapSummaryEdit string = "MapSummaryEdit" | 29 | LogDescriptionMapSummaryCreateFail string = "MapSummaryCreateFail" |
| 30 | LogDescriptionMapSummaryEditImage string = "MapSummaryEditImage" | 30 | LogDescriptionMapSummaryEditSuccess string = "MapSummaryEditSuccess" |
| 31 | LogDescriptionMapSummaryDelete string = "MapSummaryDelete" | 31 | LogDescriptionMapSummaryEditFail string = "MapSummaryEditFail" |
| 32 | LogDescriptionMapSummaryEditImage string = "MapSummaryEditImage" | ||
| 33 | LogDescriptionMapSummaryDeleteSuccess string = "MapSummaryDeleteSuccess" | ||
| 34 | LogDescriptionMapSummaryDeleteFail string = "MapSummaryDeleteFail" | ||
| 32 | 35 | ||
| 33 | LogDescriptionRecordSuccess string = "Success" | 36 | LogDescriptionRecordSuccess string = "Success" |
| 34 | LogDescriptionRecordFailInsertRecord string = "InsertRecordFail" | 37 | LogDescriptionRecordFailInsertRecord string = "InsertRecordFail" |
| @@ -177,9 +180,13 @@ func ScoreLogs(c *gin.Context) { | |||
| 177 | }) | 180 | }) |
| 178 | } | 181 | } |
| 179 | 182 | ||
| 180 | func CreateLog(user_id string, log_type string, log_description string) (err error) { | 183 | func CreateLog(userID string, logType string, logDescription string, logMessage ...string) (err error) { |
| 181 | sql := `INSERT INTO logs (user_id, "type", description) VALUES($1, $2, $3)` | 184 | message := "-" |
| 182 | _, err = database.DB.Exec(sql, user_id, log_type, log_description) | 185 | if len(logMessage) == 1 { |
| 186 | message = logMessage[0] | ||
| 187 | } | ||
| 188 | sql := `INSERT INTO logs (user_id, "type", description, message) VALUES($1, $2, $3, $4)` | ||
| 189 | _, err = database.DB.Exec(sql, userID, logType, logDescription, message) | ||
| 183 | if err != nil { | 190 | if err != nil { |
| 184 | return err | 191 | return err |
| 185 | } | 192 | } |