diff --git a/huso.go b/huso.go index d78119c..5a679c0 100644 --- a/huso.go +++ b/huso.go @@ -62,7 +62,7 @@ func main() { logOut = NewRingBuf(10101) color.Notice.Printf("huso %s %s\n", husoVersion, runtime.Version()) - logOut.WriteLine(fmt.Sprintf("huso %s %s", husoVersion, runtime.Version())) + logOut.WriteLine(fmt.Sprintf("🎉 huso %s %s", husoVersion, runtime.Version())) jikanLimiter = rate.NewLimiter(rate.Every(time.Second), 1) diff --git a/knecht.go b/knecht.go index 2b1e5c0..d538c22 100644 --- a/knecht.go +++ b/knecht.go @@ -118,13 +118,13 @@ func GetUserData(username string) (*User, []byte, error) { func GetSeasonDataAll() ([]Anime, []byte, error) { color.Infoln("Aktuelle Season abfragen...") - logOut.WriteLine("Aktuelle Season abfragen...") + logOut.WriteLine("📺 Aktuelle Season abfragen...") data, _, err := GetSeasonData(1) if err != nil { return nil, nil, err } color.Infof("%d Anime auf %d Seiten\n", data.Pagination.Items.Total, data.Pagination.LastVisiblePage) - logOut.WriteLine(fmt.Sprintf("%d Anime auf %d Seiten", data.Pagination.Items.Total, data.Pagination.LastVisiblePage)) + logOut.WriteLine(fmt.Sprintf("📺 %d Anime auf %d Seiten", data.Pagination.Items.Total, data.Pagination.LastVisiblePage)) animes := make([]Anime, 0) // convert to anime for _, a := range data.Data { @@ -132,7 +132,7 @@ func GetSeasonDataAll() ([]Anime, []byte, error) { } for i := 2; data.Pagination.HasNextPage; i++ { color.Infof("Seite %d abfragen...\n", i) - logOut.WriteLine(fmt.Sprintf("Seite %d abfragen...", i)) + logOut.WriteLine(fmt.Sprintf("📺 Seite %d abfragen...", i)) newData, _, err := GetSeasonData(i) if err != nil { return nil, nil, err @@ -146,7 +146,7 @@ func GetSeasonDataAll() ([]Anime, []byte, error) { } } color.Infof("%d Anime bekommen\n", len(animes)) - logOut.WriteLine(fmt.Sprintf("%d Anime bekommen", len(animes))) + logOut.WriteLine(fmt.Sprintf("📺 %d Anime bekommen", len(animes))) bytes, err := json.Marshal(animes) return animes, bytes, err } diff --git a/praktikant.go b/praktikant.go index 6886860..dd224ee 100644 --- a/praktikant.go +++ b/praktikant.go @@ -21,12 +21,12 @@ func Arbeit() { _, bytes, err := GetSeasonDataAll() if err != nil { color.Errorln(err.Error()) - logOut.WriteLine(err.Error()) + logOut.WriteError(err) } else { err = seasoncache.Set(seasonApiJikan, bytes) if err != nil { color.Errorln(err.Error()) - logOut.WriteLine(err.Error()) + logOut.WriteError(err) } } // refresh animelist of users @@ -34,7 +34,7 @@ func Arbeit() { if err != nil { if err != nutsdb.ErrBucketEmpty { color.Errorln(err.Error()) - logOut.WriteLine(err.Error()) + logOut.WriteError(err) } return } @@ -45,7 +45,7 @@ func Arbeit() { newProgress, updated, err := FetchProgress(a.Anime, u.MalID, u.Username, u.Progress) if err != nil { color.Errorln(err.Error()) - logOut.WriteLine(err.Error()) + logOut.WriteError(err) continue } if newProgress == u.Progress { @@ -53,11 +53,11 @@ func Arbeit() { } // update db color.Infof("%s progress von %d: %d -> %d\n", u.Username, a.Anime, u.Progress, newProgress) - logOut.WriteLine(fmt.Sprintf("%s progress von %d: %d -> %d", u.Username, a.Anime, u.Progress, newProgress)) + logOut.WriteLine(fmt.Sprintf("📜 %s progress von %d: %d -> %d", u.Username, a.Anime, u.Progress, newProgress)) err = UpdateUserAnimeProgress(a.Anime, u.MalID, newProgress, updated) if err != nil { color.Errorln(err.Error()) - logOut.WriteLine(err.Error()) + logOut.WriteError(err) } } } @@ -78,21 +78,21 @@ func LangeArbeit() { // check if no users registered if err != nutsdb.ErrBucketEmpty { color.Errorln(err.Error()) - logOut.WriteLine(err.Error()) + logOut.WriteError(err) } } else { for _, u := range regUsers { _, _, err = GetUserData(u.Username) if err != nil { color.Errorln(err.Error()) - logOut.WriteLine(err.Error()) + logOut.WriteError(err) continue } count++ } } color.Infof("%d User aktualisiert\n", count) - logOut.WriteLine(fmt.Sprintf("%d User aktualisiert", count)) + logOut.WriteLine(fmt.Sprintf("🔃 %d User aktualisiert", count)) count = 0 // refresh anime cache with watched @@ -100,7 +100,7 @@ func LangeArbeit() { if err != nil { if err != nutsdb.ErrBucketEmpty { color.Errorln(err.Error()) - logOut.WriteLine(err.Error()) + logOut.WriteError(err) } } else { for _, a := range animesUsers { @@ -112,7 +112,7 @@ func LangeArbeit() { err = refreshAnime(a.Anime) if err != nil { color.Errorln(err.Error()) - logOut.WriteLine(err.Error()) + logOut.WriteError(err) continue } count++ @@ -120,7 +120,7 @@ func LangeArbeit() { } color.Infof("%d Anime aktualisiert\n", count) - logOut.WriteLine(fmt.Sprintf("%d Anime aktualisiert", count)) + logOut.WriteLine(fmt.Sprintf("🔃 %d Anime aktualisiert", count)) } func SehrLangeArbeiten() { @@ -128,7 +128,7 @@ func SehrLangeArbeiten() { err := DbClean() if err != nil { color.Errorln(err.Error()) - logOut.WriteLine(err.Error()) + logOut.WriteError(err) } } } diff --git a/ring.go b/ring.go index 46e5e48..73d7aef 100644 --- a/ring.go +++ b/ring.go @@ -33,6 +33,10 @@ func (rb *RingBuf) WriteLine(in string) (int, error) { return rb.Write([]byte(fmt.Sprintf("[%s]: %s\n", time.Now().Format("2006-01-02 15:04:05"), in))) } +func (rb *RingBuf) WriteError(err error) (int, error) { + return rb.Write([]byte(fmt.Sprintf("[%s]: ⚠️ %s\n", time.Now().Format("2006-01-02 15:04:05"), err.Error()))) +} + // Write writes all data from input buf to RingBuf, overriding looped data func (rb *RingBuf) Write(buf []byte) (int, error) { rb.Lock()