mirror of
https://github.com/miniflux/v2.git
synced 2025-08-26 18:21:01 +00:00
Add logger
This commit is contained in:
parent
c6d9eb3614
commit
1d8193b892
56 changed files with 228 additions and 192 deletions
|
@ -6,12 +6,12 @@ package atom
|
|||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/helper"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/reader/date"
|
||||
"github.com/miniflux/miniflux/url"
|
||||
|
@ -130,7 +130,7 @@ func getDate(a *atomEntry) time.Time {
|
|||
if a.Updated != "" {
|
||||
result, err := date.Parse(a.Updated)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("atom: %v", err)
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@ package feed
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/errors"
|
||||
"github.com/miniflux/miniflux/helper"
|
||||
"github.com/miniflux/miniflux/http"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/reader/icon"
|
||||
"github.com/miniflux/miniflux/reader/processor"
|
||||
|
@ -80,13 +80,13 @@ func (h *Handler) CreateFeed(userID, categoryID int64, url string, crawler bool)
|
|||
return nil, err
|
||||
}
|
||||
|
||||
log.Println("[Handler:CreateFeed] Feed saved with ID:", subscription.ID)
|
||||
logger.Debug("[Handler:CreateFeed] Feed saved with ID: %d", subscription.ID)
|
||||
|
||||
icon, err := icon.FindIcon(subscription.SiteURL)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Handler:CreateFeed] %v", err)
|
||||
} else if icon == nil {
|
||||
log.Printf("No icon found for feedID=%d\n", subscription.ID)
|
||||
logger.Info("No icon found for feedID=%d", subscription.ID)
|
||||
} else {
|
||||
h.store.CreateFeedIcon(subscription, icon)
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ func (h *Handler) RefreshFeed(userID, feedID int64) error {
|
|||
}
|
||||
|
||||
if response.IsModified(originalFeed.EtagHeader, originalFeed.LastModifiedHeader) {
|
||||
log.Printf("[Handler:RefreshFeed] Feed #%d has been modified\n", feedID)
|
||||
logger.Debug("[Handler:RefreshFeed] Feed #%d has been modified", feedID)
|
||||
body, err := response.NormalizeBodyEncoding()
|
||||
if err != nil {
|
||||
return errors.NewLocalizedError(errEncoding, err)
|
||||
|
@ -156,16 +156,16 @@ func (h *Handler) RefreshFeed(userID, feedID int64) error {
|
|||
}
|
||||
|
||||
if !h.store.HasIcon(originalFeed.ID) {
|
||||
log.Println("[Handler:RefreshFeed] Looking for feed icon")
|
||||
logger.Debug("[Handler:RefreshFeed] Looking for feed icon")
|
||||
icon, err := icon.FindIcon(originalFeed.SiteURL)
|
||||
if err != nil {
|
||||
log.Println("[Handler:RefreshFeed]", err)
|
||||
logger.Error("[Handler:RefreshFeed] %v", err)
|
||||
} else {
|
||||
h.store.CreateFeedIcon(originalFeed, icon)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Printf("[Handler:RefreshFeed] Feed #%d not modified\n", feedID)
|
||||
logger.Debug("[Handler:RefreshFeed] Feed #%d not modified", feedID)
|
||||
}
|
||||
|
||||
originalFeed.ParsingErrorCount = 0
|
||||
|
|
|
@ -8,10 +8,10 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux/helper"
|
||||
"github.com/miniflux/miniflux/http"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/url"
|
||||
|
||||
|
@ -36,7 +36,7 @@ func FindIcon(websiteURL string) (*model.Icon, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
log.Println("[FindIcon] Fetching icon =>", iconURL)
|
||||
logger.Debug("[FindIcon] Fetching icon => %s", iconURL)
|
||||
icon, err := downloadIcon(iconURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
package json
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/helper"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/reader/date"
|
||||
"github.com/miniflux/miniflux/reader/sanitizer"
|
||||
|
@ -87,7 +87,7 @@ func (j *jsonItem) GetDate() time.Time {
|
|||
if value != "" {
|
||||
d, err := date.Parse(value)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("json: %v", err)
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/storage"
|
||||
)
|
||||
|
@ -23,7 +23,7 @@ type Handler struct {
|
|||
func (h *Handler) Export(userID int64) (string, error) {
|
||||
feeds, err := h.store.Feeds(userID)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[OPML:Export] %v", err)
|
||||
return "", errors.New("unable to fetch feeds")
|
||||
}
|
||||
|
||||
|
@ -54,13 +54,13 @@ func (h *Handler) Import(userID int64, data io.Reader) (err error) {
|
|||
if subscription.CategoryName == "" {
|
||||
category, err = h.store.FirstCategory(userID)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[OPML:Import] %v", err)
|
||||
return errors.New("unable to find first category")
|
||||
}
|
||||
} else {
|
||||
category, err = h.store.CategoryByTitle(userID, subscription.CategoryName)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[OPML:Import] %v", err)
|
||||
return errors.New("unable to search category by title")
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ func (h *Handler) Import(userID int64, data io.Reader) (err error) {
|
|||
|
||||
err := h.store.CreateCategory(category)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[OPML:Import] %v", err)
|
||||
return fmt.Errorf(`unable to create this category: "%s"`, subscription.CategoryName)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ import (
|
|||
"bufio"
|
||||
"bytes"
|
||||
"encoding/xml"
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
)
|
||||
|
||||
// Serialize returns a SubcriptionList in OPML format.
|
||||
|
@ -37,7 +38,7 @@ func Serialize(subscriptions SubcriptionList) string {
|
|||
encoder := xml.NewEncoder(writer)
|
||||
encoder.Indent(" ", " ")
|
||||
if err := encoder.Encode(feeds); err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[OPML:Serialize] %v", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
package processor
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/reader/rewrite"
|
||||
"github.com/miniflux/miniflux/reader/sanitizer"
|
||||
|
@ -42,7 +41,7 @@ func (f *FeedProcessor) Process() {
|
|||
if f.crawler {
|
||||
content, err := scraper.Fetch(entry.URL, f.scraperRules)
|
||||
if err != nil {
|
||||
log.Println("[FeedProcessor]", err)
|
||||
logger.Error("[FeedProcessor] %v", err)
|
||||
} else {
|
||||
entry.Content = content
|
||||
}
|
||||
|
|
|
@ -8,12 +8,12 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"math"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"golang.org/x/net/html"
|
||||
)
|
||||
|
||||
|
@ -83,10 +83,10 @@ func ExtractContent(page io.Reader) (string, error) {
|
|||
removeUnlikelyCandidates(document)
|
||||
|
||||
candidates := getCandidates(document)
|
||||
log.Println("Candidates:", candidates)
|
||||
logger.Debug("[Readability] Candidates: %v", candidates)
|
||||
|
||||
topCandidate := getTopCandidate(document, candidates)
|
||||
log.Println("TopCandidate:", topCandidate)
|
||||
logger.Debug("[Readability] TopCandidate: %v", topCandidate)
|
||||
|
||||
output := getArticle(topCandidate, candidates)
|
||||
return output, nil
|
||||
|
@ -142,7 +142,6 @@ func removeUnlikelyCandidates(document *goquery.Document) {
|
|||
str := class + id
|
||||
|
||||
if blacklistCandidatesRegexp.MatchString(str) || (unlikelyCandidatesRegexp.MatchString(str) && !okMaybeItsACandidateRegexp.MatchString(str)) {
|
||||
// log.Printf("Removing unlikely candidate - %s\n", str)
|
||||
removeNodes(s)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -6,13 +6,13 @@ package rss
|
|||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"log"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/helper"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/reader/date"
|
||||
"github.com/miniflux/miniflux/url"
|
||||
|
@ -130,7 +130,7 @@ func (r *rssItem) GetDate() time.Time {
|
|||
if value != "" {
|
||||
result, err := date.Parse(value)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("rss: %v", err)
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,11 @@ package scraper
|
|||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/miniflux/miniflux/http"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/reader/readability"
|
||||
"github.com/miniflux/miniflux/url"
|
||||
)
|
||||
|
@ -42,10 +42,10 @@ func Fetch(websiteURL, rules string) (string, error) {
|
|||
|
||||
var content string
|
||||
if rules != "" {
|
||||
log.Printf(`[Scraper] Using rules "%s" for "%s"`, rules, websiteURL)
|
||||
logger.Debug(`[Scraper] Using rules "%s" for "%s"`, rules, websiteURL)
|
||||
content, err = scrapContent(page, rules)
|
||||
} else {
|
||||
log.Printf(`[Scraper] Using readability for "%s"`, websiteURL)
|
||||
logger.Debug(`[Scraper] Using readability for "%s"`, websiteURL)
|
||||
content, err = readability.ExtractContent(page)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/errors"
|
||||
"github.com/miniflux/miniflux/helper"
|
||||
"github.com/miniflux/miniflux/http"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/reader/feed"
|
||||
"github.com/miniflux/miniflux/url"
|
||||
|
||||
|
@ -87,7 +87,7 @@ func parseDocument(websiteURL string, data io.Reader) (Subscriptions, error) {
|
|||
}
|
||||
|
||||
if subscription.URL != "" {
|
||||
log.Println("[FindSubscriptions]", subscription)
|
||||
logger.Debug("[FindSubscriptions] %s", subscription)
|
||||
subscriptions = append(subscriptions, subscription)
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue