diff --git a/NOTES.md b/NOTES.md index 9d4f3f9..783f1a9 100644 --- a/NOTES.md +++ b/NOTES.md @@ -1,8 +1,5 @@ # Notes -## Subscriptions -- TODO: remove all logger lines - ## Issues - URL for each tab should not be stored as a string - in the current code there's lots of reparsing the URL diff --git a/amfora.go b/amfora.go index e3c5690..62e2c6d 100644 --- a/amfora.go +++ b/amfora.go @@ -7,7 +7,6 @@ import ( "github.com/makeworld-the-better-one/amfora/client" "github.com/makeworld-the-better-one/amfora/config" "github.com/makeworld-the-better-one/amfora/display" - "github.com/makeworld-the-better-one/amfora/logger" "github.com/makeworld-the-better-one/amfora/subscriptions" ) @@ -18,10 +17,10 @@ var ( ) func main() { - err := logger.Init() - if err != nil { - panic(err) - } + // err := logger.Init() + // if err != nil { + // panic(err) + // } if len(os.Args) > 1 { if os.Args[1] == "--version" || os.Args[1] == "-v" { @@ -40,7 +39,7 @@ func main() { } } - err = config.Init() + err := config.Init() if err != nil { fmt.Fprintf(os.Stderr, "Config error: %v\n", err) os.Exit(1) diff --git a/display/subscriptions.go b/display/subscriptions.go index 27edfb9..a08e7a0 100644 --- a/display/subscriptions.go +++ b/display/subscriptions.go @@ -12,7 +12,6 @@ import ( "github.com/gdamore/tcell" "github.com/makeworld-the-better-one/amfora/cache" "github.com/makeworld-the-better-one/amfora/config" - "github.com/makeworld-the-better-one/amfora/logger" "github.com/makeworld-the-better-one/amfora/renderer" "github.com/makeworld-the-better-one/amfora/structs" "github.com/makeworld-the-better-one/amfora/subscriptions" @@ -34,8 +33,6 @@ func toLocalDay(t time.Time) time.Time { // Subscriptions displays the subscriptions page on the current tab. func Subscriptions(t *tab, u string) string { - logger.Log.Println("display.Subscriptions called") - pageN := 0 // Pages are zero-indexed internally // Correct URL if query string exists @@ -69,14 +66,11 @@ func Subscriptions(t *tab, u string) string { // Retrieve cached version if there hasn't been any updates p, ok := cache.GetPage(u) if subscriptionPageUpdated[pageN].After(subscriptions.LastUpdated) && ok { - logger.Log.Println("using cached subscriptions page") setPage(t, p) t.applyBottomBar() return u } - logger.Log.Println("started rendering subscriptions page") - pe := subscriptions.GetPageEntries() // Figure out where the entries for this page start, if at all. @@ -170,8 +164,6 @@ func Subscriptions(t *tab, u string) string { subscriptionPageUpdated[pageN] = time.Now() - logger.Log.Println("done rendering subscriptions page") - return u } @@ -235,7 +227,6 @@ func manageSubscriptionQuery(t *tab, u string) { // The subscribed arg specifies whether this feed/page is already // subscribed to. func openSubscriptionModal(validFeed, subscribed bool) bool { - logger.Log.Println("display.openFeedModal called") // Reuses yesNoModal if viper.GetBool("a-general.color") { @@ -297,8 +288,6 @@ func getFeedFromPage(p *structs.Page) (*gofeed.Feed, bool) { // // Like addFeed, it should be called in a goroutine. func addFeedDirect(u string, feed *gofeed.Feed, tracked bool) bool { - logger.Log.Println("display.addFeedDirect called") - if openSubscriptionModal(true, tracked) { err := subscriptions.AddFeed(u, feed) if err != nil { @@ -312,8 +301,6 @@ func addFeedDirect(u string, feed *gofeed.Feed, tracked bool) bool { // addFeed goes through the process of subscribing to the current page/feed. // It is the high-level way of doing it. It should be called in a goroutine. func addSubscription() { - logger.Log.Println("display.addSubscription called") - t := tabs[curTab] p := t.page diff --git a/subscriptions/entries.go b/subscriptions/entries.go index f985122..5e45f10 100644 --- a/subscriptions/entries.go +++ b/subscriptions/entries.go @@ -5,8 +5,6 @@ import ( "sort" "strings" "time" - - "github.com/makeworld-the-better-one/amfora/logger" ) // This file contains funcs for creating PageEntries, which @@ -42,8 +40,6 @@ func getURL(urls []string) string { // so this function needs to be called again to get updates. // It always returns sorted entries - by post time, from newest to oldest. func GetPageEntries() *PageEntries { - logger.Log.Println("subscriptions.GetPageEntries called") - var pe PageEntries data.RLock() diff --git a/subscriptions/subscriptions.go b/subscriptions/subscriptions.go index d12a00d..7227425 100644 --- a/subscriptions/subscriptions.go +++ b/subscriptions/subscriptions.go @@ -17,7 +17,6 @@ import ( "github.com/makeworld-the-better-one/amfora/client" "github.com/makeworld-the-better-one/amfora/config" - "github.com/makeworld-the-better-one/amfora/logger" "github.com/makeworld-the-better-one/go-gemini" "github.com/mmcdole/gofeed" "github.com/spf13/viper" @@ -90,8 +89,6 @@ func Init() error { // IsSubscribed returns true if the URL is already subscribed to, // whether a feed or page. func IsSubscribed(url string) bool { - logger.Log.Println("subscriptions.IsSubscribed called") - data.feedMu.RLock() for u := range data.Feeds { if url == u { @@ -114,8 +111,6 @@ func IsSubscribed(url string) bool { // GetFeed returns a Feed object and a bool indicating whether the passed // content was actually recognized as a feed. func GetFeed(mediatype, filename string, r io.Reader) (*gofeed.Feed, bool) { - logger.Log.Println("subscriptions.GetFeed called") - if r == nil { return nil, false } @@ -135,22 +130,17 @@ func GetFeed(mediatype, filename string, r io.Reader) (*gofeed.Feed, bool) { } func writeJSON() error { - logger.Log.Println("subscriptions.writeJSON called") - writeMu.Lock() defer writeMu.Unlock() data.Lock() - logger.Log.Println("subscriptions.writeJSON acquired data lock") jsonBytes, err := json.MarshalIndent(&data, "", " ") data.Unlock() if err != nil { - logger.Log.Println("subscriptions.writeJSON error", err) return err } err = ioutil.WriteFile(config.SubscriptionPath, jsonBytes, 0666) if err != nil { - logger.Log.Println("subscriptions.writeJSON error", err) return err } @@ -161,8 +151,6 @@ func writeJSON() error { // It can be used to update a feed for a URL, although the package // will handle that on its own. func AddFeed(url string, feed *gofeed.Feed) error { - logger.Log.Println("subscriptions.AddFeed called") - if feed == nil { panic("feed is nil") } @@ -211,8 +199,6 @@ func AddFeed(url string, feed *gofeed.Feed) error { // It can be used to update the page as well, although the package // will handle that on its own. func AddPage(url string, r io.Reader) error { - logger.Log.Println("subscriptions.AddPage called") - if r == nil { return nil } @@ -247,8 +233,6 @@ func AddPage(url string, r io.Reader) error { } func updateFeed(url string) error { - logger.Log.Println("subscriptions.updateFeed called") - res, err := client.Fetch(url) if err != nil { if res != nil { @@ -274,8 +258,6 @@ func updateFeed(url string) error { } func updatePage(url string) error { - logger.Log.Println("subscriptions.updatePage called") - res, err := client.Fetch(url) if err != nil { if res != nil { @@ -295,8 +277,6 @@ func updatePage(url string) error { // updateAll updates all subscriptions using workers. // It only returns once all the workers are done. func updateAll() { - logger.Log.Println("subscriptions.updateAll called") - // TODO: Is two goroutines the right amount? worker := func(jobs <-chan [2]string, wg *sync.WaitGroup) { @@ -333,9 +313,7 @@ func updateAll() { for w := 0; w < numWorkers; w++ { wg.Add(1) go func(i int) { - logger.Log.Println("started worker", i) worker(jobs, &wg) - logger.Log.Println("ended worker", i) }(w) }