home to your local SPACEGIRL 💫 arimelody.space
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

create log class, edit fatal-but-not-really logs

+66 -8
+4 -4
admin/releasehttp.go
··· 22 22 http.NotFound(w, r) 23 23 return 24 24 } 25 - fmt.Printf("FATAL: Failed to pull full release data for %s: %s\n", releaseID, err) 25 + fmt.Printf("WARN: Failed to pull full release data for %s: %s\n", releaseID, err) 26 26 http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) 27 27 return 28 28 } ··· 86 86 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 87 87 artists, err := controller.GetArtistsNotOnRelease(app.DB, release.ID) 88 88 if err != nil { 89 - fmt.Printf("FATAL: Failed to pull artists not on %s: %s\n", release.ID, err) 89 + fmt.Printf("WARN: Failed to pull artists not on %s: %s\n", release.ID, err) 90 90 http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) 91 91 return 92 92 } ··· 113 113 artistID := strings.Split(r.URL.Path, "/")[3] 114 114 artist, err := controller.GetArtist(app.DB, artistID) 115 115 if err != nil { 116 - fmt.Printf("FATAL: Failed to pull artists %s: %s\n", artistID, err) 116 + fmt.Printf("WARN: Failed to pull artists %s: %s\n", artistID, err) 117 117 http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) 118 118 return 119 119 } ··· 166 166 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 167 167 tracks, err := controller.GetTracksNotOnRelease(app.DB, release.ID) 168 168 if err != nil { 169 - fmt.Printf("FATAL: Failed to pull tracks not on %s: %s\n", release.ID, err) 169 + fmt.Printf("WARN: Failed to pull tracks not on %s: %s\n", release.ID, err) 170 170 http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) 171 171 return 172 172 }
+3 -3
api/api.go
··· 27 27 http.NotFound(w, r) 28 28 return 29 29 } 30 - fmt.Printf("FATAL: Error while retrieving artist %s: %s\n", artistID, err) 30 + fmt.Printf("WARN: Error while retrieving artist %s: %s\n", artistID, err) 31 31 http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) 32 32 return 33 33 } ··· 69 69 http.NotFound(w, r) 70 70 return 71 71 } 72 - fmt.Printf("FATAL: Error while retrieving release %s: %s\n", releaseID, err) 72 + fmt.Printf("WARN: Error while retrieving release %s: %s\n", releaseID, err) 73 73 http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) 74 74 return 75 75 } ··· 111 111 http.NotFound(w, r) 112 112 return 113 113 } 114 - fmt.Printf("FATAL: Error while retrieving track %s: %s\n", trackID, err) 114 + fmt.Printf("WARN: Error while retrieving track %s: %s\n", trackID, err) 115 115 http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) 116 116 return 117 117 }
+58
log/log.go
··· 1 + package log 2 + 3 + import ( 4 + "fmt" 5 + "os" 6 + "time" 7 + 8 + "github.com/jmoiron/sqlx" 9 + ) 10 + 11 + type ( 12 + Logger struct { 13 + DB *sqlx.DB 14 + } 15 + 16 + Log struct { 17 + ID string `json:"id" db:"id"` 18 + Type string `json:"type" db:"type"` 19 + Content string `json:"content" db:"content"` 20 + CreatedAt time.Time `json:"created_at" db:"created_at"` 21 + } 22 + ) 23 + 24 + const ( 25 + TYPE_ACCOUNT = "account" 26 + ) 27 + 28 + func (self *Logger) Info(logType string, format string, args ...any) { 29 + fmt.Printf(fmt.Sprintf("[%s] INFO: %s", logType, format), args...) 30 + // TODO: push logs to DB 31 + } 32 + 33 + func (self *Logger) Warn(logType string, format string, args ...any) { 34 + fmt.Fprintf(os.Stderr, fmt.Sprintf("[%s] WARN: %s", logType, format), args...) 35 + // TODO: push logs to DB 36 + } 37 + 38 + func (self *Logger) Fatal(logType string, format string, args ...any) { 39 + fmt.Fprintf(os.Stderr, fmt.Sprintf("[%s] FATAL: %s", logType, format), args...) 40 + // we won't need to push fatal logs to DB, as these usually precede a panic or crash 41 + } 42 + 43 + func (self *Logger) Fetch(id string) *Log { 44 + // TODO: log fetch 45 + return nil 46 + } 47 + 48 + func (self *Logger) Search(typeFilters []string, content string, offset int, limit int) []Log { 49 + // TODO: log search 50 + return []Log{} 51 + } 52 + 53 + func (self *Logger) Delete(id string) error { 54 + // TODO: log deletion 55 + // consider: logging the deletion of logs? 56 + // or just not deleting logs at all 57 + return nil 58 + }
+1 -1
view/music.go
··· 37 37 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 38 38 releases, err := controller.GetAllReleases(app.DB, true, 0, true) 39 39 if err != nil { 40 - fmt.Printf("FATAL: Failed to pull releases for catalog: %s\n", err) 40 + fmt.Printf("WARN: Failed to pull releases for catalog: %s\n", err) 41 41 http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) 42 42 return 43 43 }