Add logger
This commit is contained in:
parent
c6d9eb3614
commit
1d8193b892
56 changed files with 228 additions and 192 deletions
|
@ -5,12 +5,13 @@
|
|||
package helper
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
)
|
||||
|
||||
// ExecutionTime returns the elapsed time of a block of code.
|
||||
func ExecutionTime(start time.Time, name string) {
|
||||
elapsed := time.Since(start)
|
||||
log.Printf("%s took %s", name, elapsed)
|
||||
logger.Debug("%s took %s", name, elapsed)
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@ package http
|
|||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/helper"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
)
|
||||
|
||||
const userAgent = "Miniflux <https://miniflux.net/>"
|
||||
|
@ -47,7 +47,7 @@ func (c *Client) Get() (*Response, error) {
|
|||
ContentType: resp.Header.Get("Content-Type"),
|
||||
}
|
||||
|
||||
log.Println("[HttpClient:Get]",
|
||||
logger.Debug("[HttpClient:Get]",
|
||||
"OriginalURL:", c.url,
|
||||
"StatusCode:", response.StatusCode,
|
||||
"ETag:", response.ETag,
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
package integration
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux/integration/instapaper"
|
||||
"github.com/miniflux/miniflux/integration/pinboard"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
)
|
||||
|
||||
|
@ -18,7 +17,7 @@ func SendEntry(entry *model.Entry, integration *model.Integration) {
|
|||
client := pinboard.NewClient(integration.PinboardToken)
|
||||
err := client.AddBookmark(entry.URL, entry.Title, integration.PinboardTags, integration.PinboardMarkAsUnread)
|
||||
if err != nil {
|
||||
log.Println("[Pinboard]", err)
|
||||
logger.Error("[Pinboard] %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +25,7 @@ func SendEntry(entry *model.Entry, integration *model.Integration) {
|
|||
client := instapaper.NewClient(integration.InstapaperUsername, integration.InstapaperPassword)
|
||||
err := client.AddURL(entry.URL, entry.Title)
|
||||
if err != nil {
|
||||
log.Println("[Instapaper]", err)
|
||||
logger.Error("[Instapaper] %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
package locale
|
||||
|
||||
import "log"
|
||||
import "github.com/miniflux/miniflux/logger"
|
||||
|
||||
// Translation is the translation mapping table.
|
||||
type Translation map[string]interface{}
|
||||
|
@ -17,7 +17,7 @@ func Load() *Translator {
|
|||
translator := NewTranslator()
|
||||
|
||||
for language, tr := range translations {
|
||||
log.Println("Loading translation:", language)
|
||||
logger.Debug("Loading translation: %s", language)
|
||||
translator.AddLanguage(language, tr)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2017-12-12 21:44:02.672642313 -0800 PST m=+0.027053016
|
||||
// 2017-12-15 18:49:24.054372873 -0800 PST m=+0.026968745
|
||||
|
||||
package locale
|
||||
|
||||
|
|
37
logger/logger.go
Normal file
37
logger/logger.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2017 Frédéric Guillot. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package logger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Debug sends a debug log message.
|
||||
func Debug(format string, v ...interface{}) {
|
||||
formatMessage("DEBUG", format, v...)
|
||||
}
|
||||
|
||||
// Info sends an info log message.
|
||||
func Info(format string, v ...interface{}) {
|
||||
formatMessage("INFO", format, v...)
|
||||
}
|
||||
|
||||
// Error sends an error log message.
|
||||
func Error(format string, v ...interface{}) {
|
||||
formatMessage("ERROR", format, v...)
|
||||
}
|
||||
|
||||
// Fatal sends a fatal log message and stop the execution of the program.
|
||||
func Fatal(format string, v ...interface{}) {
|
||||
formatMessage("FATAL", format, v...)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func formatMessage(level, format string, v ...interface{}) {
|
||||
prefix := fmt.Sprintf("[%s] [%s] ", time.Now().Format("2006-01-02T15:04:05"), level)
|
||||
fmt.Fprintf(os.Stderr, prefix+format+"\n", v...)
|
||||
}
|
8
main.go
8
main.go
|
@ -18,7 +18,6 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
|
@ -26,6 +25,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/config"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/reader/feed"
|
||||
"github.com/miniflux/miniflux/scheduler"
|
||||
|
@ -38,7 +38,7 @@ import (
|
|||
)
|
||||
|
||||
func run(cfg *config.Config, store *storage.Storage) {
|
||||
log.Println("Starting Miniflux...")
|
||||
logger.Info("Starting Miniflux...")
|
||||
|
||||
stop := make(chan os.Signal, 1)
|
||||
signal.Notify(stop, os.Interrupt)
|
||||
|
@ -55,11 +55,11 @@ func run(cfg *config.Config, store *storage.Storage) {
|
|||
)
|
||||
|
||||
<-stop
|
||||
log.Println("Shutting down the server...")
|
||||
logger.Info("Shutting down the server...")
|
||||
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
server.Shutdown(ctx)
|
||||
store.Close()
|
||||
log.Println("Server gracefully stopped")
|
||||
logger.Info("Server gracefully stopped")
|
||||
}
|
||||
|
||||
func askCredentials() (string, string) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
package scheduler
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/storage"
|
||||
)
|
||||
|
||||
|
@ -18,9 +18,9 @@ func NewScheduler(store *storage.Storage, workerPool *WorkerPool, frequency, bat
|
|||
for now := range c {
|
||||
jobs, err := store.NewBatch(batchSize)
|
||||
if err != nil {
|
||||
log.Println("[Scheduler]", err)
|
||||
logger.Error("[Scheduler] %v", err)
|
||||
} else {
|
||||
log.Printf("[Scheduler:%v] => Pushing %d jobs\n", now, len(jobs))
|
||||
logger.Debug("[Scheduler:%v] => Pushing %d jobs", now, len(jobs))
|
||||
workerPool.Push(jobs)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
package scheduler
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/reader/feed"
|
||||
)
|
||||
|
@ -20,15 +20,15 @@ type Worker struct {
|
|||
|
||||
// Run wait for a job and refresh the given feed.
|
||||
func (w *Worker) Run(c chan model.Job) {
|
||||
log.Printf("[Worker] #%d started\n", w.id)
|
||||
logger.Debug("[Worker] #%d started", w.id)
|
||||
|
||||
for {
|
||||
job := <-c
|
||||
log.Printf("[Worker #%d] got userID=%d, feedID=%d\n", w.id, job.UserID, job.FeedID)
|
||||
logger.Debug("[Worker #%d] got userID=%d, feedID=%d", w.id, job.UserID, job.FeedID)
|
||||
|
||||
err := w.feedHandler.RefreshFeed(job.UserID, job.FeedID)
|
||||
if err != nil {
|
||||
log.Println("Worker:", err)
|
||||
logger.Error("[Worker] %v", err)
|
||||
}
|
||||
|
||||
time.Sleep(time.Millisecond * 1000)
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/server/middleware"
|
||||
"github.com/miniflux/miniflux/server/route"
|
||||
|
@ -63,11 +63,11 @@ func (c *Context) LoggedUser() *model.User {
|
|||
var err error
|
||||
c.user, err = c.store.UserByID(c.UserID())
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
logger.Fatal("[Context] %v", err)
|
||||
}
|
||||
|
||||
if c.user == nil {
|
||||
log.Fatalln("Unable to find user from context")
|
||||
logger.Fatal("Unable to find user from context")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ func (c *Context) CsrfToken() string {
|
|||
return v.(string)
|
||||
}
|
||||
|
||||
log.Println("No CSRF token in context!")
|
||||
logger.Error("No CSRF token in context!")
|
||||
return ""
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/helper"
|
||||
"github.com/miniflux/miniflux/locale"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/server/middleware"
|
||||
"github.com/miniflux/miniflux/server/template"
|
||||
"github.com/miniflux/miniflux/storage"
|
||||
|
@ -34,7 +34,7 @@ type Handler struct {
|
|||
func (h *Handler) Use(f HandlerFunc) http.Handler {
|
||||
return h.middleware.WrapFunc(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
defer helper.ExecutionTime(time.Now(), r.URL.Path)
|
||||
log.Println(r.Method, r.URL.Path)
|
||||
logger.Debug("[HTTP] %s %s", r.Method, r.URL.Path)
|
||||
|
||||
ctx := NewContext(w, r, h.store, h.router)
|
||||
request := NewRequest(w, r)
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/server/template"
|
||||
)
|
||||
|
||||
|
@ -30,7 +30,7 @@ func (h *HTMLResponse) ServerError(err error) {
|
|||
h.writer.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Internal Server Error] %v", err)
|
||||
h.writer.Write([]byte("Internal Server Error: " + err.Error()))
|
||||
} else {
|
||||
h.writer.Write([]byte("Internal Server Error"))
|
||||
|
@ -43,7 +43,7 @@ func (h *HTMLResponse) BadRequest(err error) {
|
|||
h.writer.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Bad Request] %v", err)
|
||||
h.writer.Write([]byte("Bad Request: " + err.Error()))
|
||||
} else {
|
||||
h.writer.Write([]byte("Bad Request"))
|
||||
|
|
|
@ -7,8 +7,9 @@ package core
|
|||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
)
|
||||
|
||||
// JSONResponse handles JSON responses.
|
||||
|
@ -39,7 +40,7 @@ func (j *JSONResponse) NoContent() {
|
|||
|
||||
// BadRequest sends a JSON response with the status code 400.
|
||||
func (j *JSONResponse) BadRequest(err error) {
|
||||
log.Println("[API:BadRequest]", err)
|
||||
logger.Error("[Bad Request] %v", err)
|
||||
j.writer.WriteHeader(http.StatusBadRequest)
|
||||
j.commonHeaders()
|
||||
|
||||
|
@ -50,7 +51,7 @@ func (j *JSONResponse) BadRequest(err error) {
|
|||
|
||||
// NotFound sends a JSON response with the status code 404.
|
||||
func (j *JSONResponse) NotFound(err error) {
|
||||
log.Println("[API:NotFound]", err)
|
||||
logger.Error("[Not Found] %v", err)
|
||||
j.writer.WriteHeader(http.StatusNotFound)
|
||||
j.commonHeaders()
|
||||
j.writer.Write(j.encodeError(err))
|
||||
|
@ -58,7 +59,7 @@ func (j *JSONResponse) NotFound(err error) {
|
|||
|
||||
// ServerError sends a JSON response with the status code 500.
|
||||
func (j *JSONResponse) ServerError(err error) {
|
||||
log.Println("[API:ServerError]", err)
|
||||
logger.Error("[Internal Server Error] %v", err)
|
||||
j.writer.WriteHeader(http.StatusInternalServerError)
|
||||
j.commonHeaders()
|
||||
|
||||
|
@ -69,7 +70,7 @@ func (j *JSONResponse) ServerError(err error) {
|
|||
|
||||
// Forbidden sends a JSON response with the status code 403.
|
||||
func (j *JSONResponse) Forbidden() {
|
||||
log.Println("[API:Forbidden]")
|
||||
logger.Info("[API:Forbidden]")
|
||||
j.writer.WriteHeader(http.StatusForbidden)
|
||||
j.commonHeaders()
|
||||
j.writer.Write(j.encodeError(errors.New("Access Forbidden")))
|
||||
|
@ -88,7 +89,7 @@ func (j *JSONResponse) encodeError(err error) []byte {
|
|||
tmp := errorMsg{ErrorMessage: err.Error()}
|
||||
data, err := json.Marshal(tmp)
|
||||
if err != nil {
|
||||
log.Println("encodeError:", err)
|
||||
logger.Error("encoding error: %v", err)
|
||||
}
|
||||
|
||||
return data
|
||||
|
@ -97,7 +98,7 @@ func (j *JSONResponse) encodeError(err error) []byte {
|
|||
func (j *JSONResponse) toJSON(v interface{}) []byte {
|
||||
b, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
log.Println("Unable to convert interface to JSON:", err)
|
||||
logger.Error("encoding error: %v", err)
|
||||
return []byte("")
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ package core
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
)
|
||||
|
||||
// Request is a thin wrapper around "http.Request".
|
||||
|
@ -68,7 +68,7 @@ func (r *Request) IntegerParam(param string) (int64, error) {
|
|||
vars := mux.Vars(r.request)
|
||||
value, err := strconv.Atoi(vars[param])
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[IntegerParam] %v", err)
|
||||
return 0, fmt.Errorf("%s parameter is not an integer", param)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
package fever
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/integration"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/server/core"
|
||||
"github.com/miniflux/miniflux/storage"
|
||||
|
@ -183,7 +183,7 @@ is_spark equal to 1.
|
|||
*/
|
||||
func (c *Controller) handleGroups(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
userID := ctx.UserID()
|
||||
log.Printf("[Fever] Fetching groups for userID=%d\n", userID)
|
||||
logger.Debug("[Fever] Fetching groups for userID=%d", userID)
|
||||
|
||||
categories, err := c.store.Categories(userID)
|
||||
if err != nil {
|
||||
|
@ -233,7 +233,7 @@ For the “Sparks” super group the items should be limited to feeds with an is
|
|||
*/
|
||||
func (c *Controller) handleFeeds(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
userID := ctx.UserID()
|
||||
log.Printf("[Fever] Fetching feeds for userID=%d\n", userID)
|
||||
logger.Debug("[Fever] Fetching feeds for userID=%d", userID)
|
||||
|
||||
feeds, err := c.store.Feeds(userID)
|
||||
if err != nil {
|
||||
|
@ -280,7 +280,7 @@ A PHP/HTML example:
|
|||
*/
|
||||
func (c *Controller) handleFavicons(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
userID := ctx.UserID()
|
||||
log.Printf("[Fever] Fetching favicons for userID=%d\n", userID)
|
||||
logger.Debug("[Fever] Fetching favicons for userID=%d", userID)
|
||||
|
||||
icons, err := c.store.Icons(userID)
|
||||
if err != nil {
|
||||
|
@ -336,7 +336,7 @@ func (c *Controller) handleItems(ctx *core.Context, request *core.Request, respo
|
|||
|
||||
userID := ctx.UserID()
|
||||
timezone := ctx.UserTimezone()
|
||||
log.Printf("[Fever] Fetching items for userID=%d\n", userID)
|
||||
logger.Debug("[Fever] Fetching items for userID=%d", userID)
|
||||
|
||||
builder := c.store.GetEntryQueryBuilder(userID, timezone)
|
||||
builder.WithoutStatus(model.EntryStatusRemoved)
|
||||
|
@ -413,7 +413,7 @@ A request with the unread_item_ids argument will return one additional member:
|
|||
*/
|
||||
func (c *Controller) handleUnreadItems(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
userID := ctx.UserID()
|
||||
log.Printf("[Fever] Fetching unread items for userID=%d\n", userID)
|
||||
logger.Debug("[Fever] Fetching unread items for userID=%d", userID)
|
||||
|
||||
builder := c.store.GetEntryQueryBuilder(userID, ctx.UserTimezone())
|
||||
builder.WithStatus(model.EntryStatusUnread)
|
||||
|
@ -444,7 +444,7 @@ with the remote Fever installation.
|
|||
*/
|
||||
func (c *Controller) handleSavedItems(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
userID := ctx.UserID()
|
||||
log.Printf("[Fever] Fetching saved items for userID=%d\n", userID)
|
||||
logger.Debug("[Fever] Fetching saved items for userID=%d", userID)
|
||||
|
||||
var result savedResponse
|
||||
result.SetCommonValues()
|
||||
|
@ -471,7 +471,7 @@ A link object has the following members:
|
|||
*/
|
||||
func (c *Controller) handleLinks(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
userID := ctx.UserID()
|
||||
log.Printf("[Fever] Fetching links for userID=%d\n", userID)
|
||||
logger.Debug("[Fever] Fetching links for userID=%d", userID)
|
||||
|
||||
var result linksResponse
|
||||
result.SetCommonValues()
|
||||
|
@ -485,7 +485,7 @@ func (c *Controller) handleLinks(ctx *core.Context, request *core.Request, respo
|
|||
*/
|
||||
func (c *Controller) handleWriteItems(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
userID := ctx.UserID()
|
||||
log.Printf("[Fever] Receiving mark=item call for userID=%d\n", userID)
|
||||
logger.Debug("[Fever] Receiving mark=item call for userID=%d", userID)
|
||||
|
||||
entryID := request.FormIntegerValue("id")
|
||||
if entryID <= 0 {
|
||||
|
@ -534,7 +534,7 @@ func (c *Controller) handleWriteItems(ctx *core.Context, request *core.Request,
|
|||
*/
|
||||
func (c *Controller) handleWriteFeeds(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
userID := ctx.UserID()
|
||||
log.Printf("[Fever] Receiving mark=feed call for userID=%d\n", userID)
|
||||
logger.Debug("[Fever] Receiving mark=feed call for userID=%d", userID)
|
||||
|
||||
feedID := request.FormIntegerValue("id")
|
||||
if feedID <= 0 {
|
||||
|
@ -574,7 +574,7 @@ func (c *Controller) handleWriteFeeds(ctx *core.Context, request *core.Request,
|
|||
*/
|
||||
func (c *Controller) handleWriteGroups(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
userID := ctx.UserID()
|
||||
log.Printf("[Fever] Receiving mark=group call for userID=%d\n", userID)
|
||||
logger.Debug("[Fever] Receiving mark=group call for userID=%d", userID)
|
||||
|
||||
groupID := request.FormIntegerValue("id")
|
||||
if groupID < 0 {
|
||||
|
|
|
@ -6,9 +6,9 @@ package middleware
|
|||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/storage"
|
||||
)
|
||||
|
||||
|
@ -25,14 +25,14 @@ func (b *BasicAuthMiddleware) Handler(next http.Handler) http.Handler {
|
|||
|
||||
username, password, authOK := r.BasicAuth()
|
||||
if !authOK {
|
||||
log.Println("[Middleware:BasicAuth] No authentication headers sent")
|
||||
logger.Debug("[Middleware:BasicAuth] No authentication headers sent")
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
w.Write([]byte(errorResponse))
|
||||
return
|
||||
}
|
||||
|
||||
if err := b.store.CheckPassword(username, password); err != nil {
|
||||
log.Println("[Middleware:BasicAuth] Invalid username or password:", username)
|
||||
logger.Info("[Middleware:BasicAuth] Invalid username or password: %s", username)
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
w.Write([]byte(errorResponse))
|
||||
return
|
||||
|
@ -40,13 +40,13 @@ func (b *BasicAuthMiddleware) Handler(next http.Handler) http.Handler {
|
|||
|
||||
user, err := b.store.UserByUsername(username)
|
||||
if err != nil || user == nil {
|
||||
log.Println("[Middleware:BasicAuth] User not found:", username)
|
||||
logger.Info("[Middleware:BasicAuth] User not found: %s", username)
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
w.Write([]byte(errorResponse))
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("[Middleware:BasicAuth] User authenticated:", username)
|
||||
logger.Info("[Middleware:BasicAuth] User authenticated: %s", username)
|
||||
b.store.SetLastLogin(user.ID)
|
||||
|
||||
ctx := r.Context()
|
||||
|
|
|
@ -6,9 +6,9 @@ package middleware
|
|||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/storage"
|
||||
)
|
||||
|
||||
|
@ -20,25 +20,25 @@ type FeverMiddleware struct {
|
|||
// Handler executes the middleware.
|
||||
func (f *FeverMiddleware) Handler(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println("[Middleware:Fever]")
|
||||
logger.Debug("[Middleware:Fever]")
|
||||
|
||||
apiKey := r.FormValue("api_key")
|
||||
user, err := f.store.UserByFeverToken(apiKey)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Fever] %v", err)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write([]byte(`{"api_version": 3, "auth": 0}`))
|
||||
return
|
||||
}
|
||||
|
||||
if user == nil {
|
||||
log.Println("[Middleware:Fever] Fever authentication failure")
|
||||
logger.Info("[Middleware:Fever] Fever authentication failure")
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write([]byte(`{"api_version": 3, "auth": 0}`))
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("[Middleware:Fever] User #%d is authenticated\n", user.ID)
|
||||
logger.Info("[Middleware:Fever] User #%d is authenticated", user.ID)
|
||||
f.store.SetLastLogin(user.ID)
|
||||
|
||||
ctx := r.Context()
|
||||
|
|
|
@ -6,9 +6,9 @@ package middleware
|
|||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/server/route"
|
||||
"github.com/miniflux/miniflux/storage"
|
||||
|
@ -28,14 +28,14 @@ func (s *SessionMiddleware) Handler(next http.Handler) http.Handler {
|
|||
session := s.getSessionFromCookie(r)
|
||||
|
||||
if session == nil {
|
||||
log.Println("[Middleware:Session] Session not found")
|
||||
logger.Debug("[Middleware:Session] Session not found")
|
||||
if s.isPublicRoute(r) {
|
||||
next.ServeHTTP(w, r)
|
||||
} else {
|
||||
http.Redirect(w, r, route.Path(s.router, "login"), http.StatusFound)
|
||||
}
|
||||
} else {
|
||||
log.Println("[Middleware:Session]", session)
|
||||
logger.Debug("[Middleware:Session] %s", session)
|
||||
ctx := r.Context()
|
||||
ctx = context.WithValue(ctx, UserIDContextKey, session.UserID)
|
||||
ctx = context.WithValue(ctx, IsAuthenticatedContextKey, true)
|
||||
|
@ -63,7 +63,7 @@ func (s *SessionMiddleware) getSessionFromCookie(r *http.Request) *model.Session
|
|||
|
||||
session, err := s.store.SessionByToken(sessionCookie.Value)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[SessionMiddleware] %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ package middleware
|
|||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/storage"
|
||||
)
|
||||
|
@ -25,10 +25,10 @@ func (t *TokenMiddleware) Handler(next http.Handler) http.Handler {
|
|||
token := t.getTokenValueFromCookie(r)
|
||||
|
||||
if token == nil {
|
||||
log.Println("[Middleware:Token] Token not found")
|
||||
logger.Debug("[Middleware:Token] Token not found")
|
||||
token, err = t.store.CreateToken()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Middleware:Token] %v", err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
@ -43,13 +43,13 @@ func (t *TokenMiddleware) Handler(next http.Handler) http.Handler {
|
|||
|
||||
http.SetCookie(w, cookie)
|
||||
} else {
|
||||
log.Println("[Middleware:Token]", token)
|
||||
logger.Info("[Middleware:Token] %s", token)
|
||||
}
|
||||
|
||||
isTokenValid := token.Value == r.FormValue("csrf") || token.Value == r.Header.Get("X-Csrf-Token")
|
||||
|
||||
if r.Method == "POST" && !isTokenValid {
|
||||
log.Println("[Middleware:CSRF] Invalid or missing CSRF token!")
|
||||
logger.Error("[Middleware:CSRF] Invalid or missing CSRF token!")
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
w.Write([]byte("Invalid or missing CSRF token!"))
|
||||
} else {
|
||||
|
@ -68,7 +68,7 @@ func (t *TokenMiddleware) getTokenValueFromCookie(r *http.Request) *model.Token
|
|||
|
||||
token, err := t.store.Token(tokenCookie.Value)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Middleware:Token] %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
package route
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
)
|
||||
|
||||
// Path returns the defined route based on given arguments.
|
||||
func Path(router *mux.Router, name string, args ...interface{}) string {
|
||||
route := router.Get(name)
|
||||
if route == nil {
|
||||
log.Fatalln("Route not found:", name)
|
||||
logger.Fatal("[Route] Route not found: %s", name)
|
||||
}
|
||||
|
||||
var pairs []string
|
||||
|
@ -31,7 +31,7 @@ func Path(router *mux.Router, name string, args ...interface{}) string {
|
|||
|
||||
result, err := route.URLPath(pairs...)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
logger.Fatal("[Route] %v", err)
|
||||
}
|
||||
|
||||
return result.String()
|
||||
|
|
|
@ -6,11 +6,11 @@ package server
|
|||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/scheduler"
|
||||
"golang.org/x/crypto/acme/autocert"
|
||||
|
||||
|
@ -46,20 +46,20 @@ func startServer(cfg *config.Config, handler *mux.Router) *http.Server {
|
|||
}
|
||||
|
||||
go func() {
|
||||
log.Printf(`Listening on "%s" by using auto-configured certificate for "%s"`, server.Addr, certDomain)
|
||||
log.Fatalln(server.Serve(certManager.Listener()))
|
||||
logger.Info(`Listening on "%s" by using auto-configured certificate for "%s"`, server.Addr, certDomain)
|
||||
logger.Fatal(server.Serve(certManager.Listener()).Error())
|
||||
}()
|
||||
} else if certFile != "" && keyFile != "" {
|
||||
server.TLSConfig = &tls.Config{MinVersion: tls.VersionTLS12}
|
||||
|
||||
go func() {
|
||||
log.Printf(`Listening on "%s" by using certificate "%s" and key "%s"`, server.Addr, certFile, keyFile)
|
||||
log.Fatalln(server.ListenAndServeTLS(certFile, keyFile))
|
||||
logger.Info(`Listening on "%s" by using certificate "%s" and key "%s"`, server.Addr, certFile, keyFile)
|
||||
logger.Fatal(server.ListenAndServeTLS(certFile, keyFile).Error())
|
||||
}()
|
||||
} else {
|
||||
go func() {
|
||||
log.Printf(`Listening on "%s" without TLS`, server.Addr)
|
||||
log.Fatalln(server.ListenAndServe())
|
||||
logger.Info(`Listening on "%s" without TLS`, server.Addr)
|
||||
logger.Fatal(server.ListenAndServe().Error())
|
||||
}()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2017-12-12 21:44:02.652999925 -0800 PST m=+0.007410628
|
||||
// 2017-12-15 18:49:24.03816003 -0800 PST m=+0.010755902
|
||||
|
||||
package static
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2017-12-13 20:40:03.300001544 -0800 PST m=+0.017854402
|
||||
// 2017-12-15 18:49:24.040014054 -0800 PST m=+0.012609926
|
||||
|
||||
package static
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2017-12-12 21:44:02.656535482 -0800 PST m=+0.010946185
|
||||
// 2017-12-15 18:49:24.041876548 -0800 PST m=+0.014472420
|
||||
|
||||
package static
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2017-12-12 21:44:02.670455816 -0800 PST m=+0.024866519
|
||||
// 2017-12-15 18:49:24.05332735 -0800 PST m=+0.025923222
|
||||
|
||||
package template
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"bytes"
|
||||
"html/template"
|
||||
"io"
|
||||
"log"
|
||||
"net/mail"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -16,6 +15,7 @@ import (
|
|||
"github.com/miniflux/miniflux/config"
|
||||
"github.com/miniflux/miniflux/errors"
|
||||
"github.com/miniflux/miniflux/locale"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/server/route"
|
||||
"github.com/miniflux/miniflux/server/template/helper"
|
||||
"github.com/miniflux/miniflux/server/ui/filter"
|
||||
|
@ -42,7 +42,6 @@ func (e *Engine) parseAll() {
|
|||
return e.cfg.Get("OAUTH2_PROVIDER", "") == provider
|
||||
},
|
||||
"hasKey": func(dict map[string]string, key string) bool {
|
||||
log.Println(dict)
|
||||
if value, found := dict[key]; found {
|
||||
return value != ""
|
||||
}
|
||||
|
@ -110,7 +109,7 @@ func (e *Engine) parseAll() {
|
|||
}
|
||||
|
||||
for name, content := range templateViewsMap {
|
||||
log.Println("Parsing template:", name)
|
||||
logger.Debug("[Template] Parsing: %s", name)
|
||||
e.templates[name] = template.Must(template.New("main").Funcs(funcMap).Parse(commonTemplates + content))
|
||||
}
|
||||
}
|
||||
|
@ -124,13 +123,13 @@ func (e *Engine) SetLanguage(language string) {
|
|||
func (e *Engine) Execute(w io.Writer, name string, data interface{}) {
|
||||
tpl, ok := e.templates[name]
|
||||
if !ok {
|
||||
log.Fatalf("The template %s does not exists.\n", name)
|
||||
logger.Fatal("[Template] The template %s does not exists", name)
|
||||
}
|
||||
|
||||
var b bytes.Buffer
|
||||
err := tpl.ExecuteTemplate(&b, "base", data)
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to render template: %v\n", err)
|
||||
logger.Fatal("[Template] Unable to render template: %v", err)
|
||||
}
|
||||
|
||||
b.WriteTo(w)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2017-12-12 21:44:02.658745181 -0800 PST m=+0.013155884
|
||||
// 2017-12-15 18:49:24.044316922 -0800 PST m=+0.016912794
|
||||
|
||||
package template
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ package controller
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/server/core"
|
||||
"github.com/miniflux/miniflux/server/ui/form"
|
||||
|
@ -126,7 +126,7 @@ func (c *Controller) SaveCategory(ctx *core.Context, request *core.Request, resp
|
|||
category := model.Category{Title: categoryForm.Title, UserID: user.ID}
|
||||
err = c.store.CreateCategory(&category)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Info("[Controller:CreateCategory] %v", err)
|
||||
response.HTML().Render("create_category", args.Merge(tplParams{
|
||||
"errorMessage": "Unable to create this category.",
|
||||
}))
|
||||
|
@ -142,7 +142,7 @@ func (c *Controller) EditCategory(ctx *core.Context, request *core.Request, resp
|
|||
|
||||
category, err := c.getCategoryFromURL(ctx, request, response)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:EditCategory] %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ func (c *Controller) UpdateCategory(ctx *core.Context, request *core.Request, re
|
|||
|
||||
category, err := c.getCategoryFromURL(ctx, request, response)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:UpdateCategory] %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ func (c *Controller) UpdateCategory(ctx *core.Context, request *core.Request, re
|
|||
|
||||
err = c.store.UpdateCategory(categoryForm.Merge(category))
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:UpdateCategory] %v", err)
|
||||
response.HTML().Render("edit_category", args.Merge(tplParams{
|
||||
"errorMessage": "Unable to update this category.",
|
||||
}))
|
||||
|
|
|
@ -6,8 +6,8 @@ package controller
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/reader/sanitizer"
|
||||
|
||||
"github.com/miniflux/miniflux/integration"
|
||||
|
@ -126,7 +126,7 @@ func (c *Controller) ShowFeedEntry(ctx *core.Context, request *core.Request, res
|
|||
if entry.Status == model.EntryStatusUnread {
|
||||
err = c.store.SetEntriesStatus(user.ID, []int64{entry.ID}, model.EntryStatusRead)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:ShowFeedEntry] %v", err)
|
||||
response.HTML().ServerError(nil)
|
||||
return
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ func (c *Controller) ShowCategoryEntry(ctx *core.Context, request *core.Request,
|
|||
if entry.Status == model.EntryStatusUnread {
|
||||
err = c.store.SetEntriesStatus(user.ID, []int64{entry.ID}, model.EntryStatusRead)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:ShowCategoryEntry] %v", err)
|
||||
response.HTML().ServerError(nil)
|
||||
return
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ func (c *Controller) ShowUnreadEntry(ctx *core.Context, request *core.Request, r
|
|||
if entry.Status == model.EntryStatusUnread {
|
||||
err = c.store.SetEntriesStatus(user.ID, []int64{entry.ID}, model.EntryStatusRead)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:ShowUnreadEntry] %v", err)
|
||||
response.HTML().ServerError(nil)
|
||||
return
|
||||
}
|
||||
|
@ -379,7 +379,7 @@ func (c *Controller) UpdateEntriesStatus(ctx *core.Context, request *core.Reques
|
|||
|
||||
entryIDs, status, err := payload.DecodeEntryStatusPayload(request.Body())
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:UpdateEntryStatus] %v", err)
|
||||
response.JSON().BadRequest(nil)
|
||||
return
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ func (c *Controller) UpdateEntriesStatus(ctx *core.Context, request *core.Reques
|
|||
|
||||
err = c.store.SetEntriesStatus(user.ID, entryIDs, status)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:UpdateEntryStatus] %v", err)
|
||||
response.JSON().ServerError(nil)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ package controller
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/server/core"
|
||||
"github.com/miniflux/miniflux/server/ui/form"
|
||||
|
@ -140,7 +140,7 @@ func (c *Controller) UpdateFeed(ctx *core.Context, request *core.Request, respon
|
|||
|
||||
err = c.store.UpdateFeed(feedForm.Merge(feed))
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:EditFeed] %v", err)
|
||||
response.HTML().Render("edit_feed", args.Merge(tplParams{
|
||||
"errorMessage": "Unable to update this feed.",
|
||||
}))
|
||||
|
@ -177,7 +177,7 @@ func (c *Controller) RefreshFeed(ctx *core.Context, request *core.Request, respo
|
|||
|
||||
user := ctx.LoggedUser()
|
||||
if err := c.feedHandler.RefreshFeed(user.ID, feedID); err != nil {
|
||||
log.Println("[UI:RefreshFeed]", err)
|
||||
logger.Error("[Controller:RefreshFeed] %v", err)
|
||||
}
|
||||
|
||||
response.Redirect(ctx.Route("feedEntries", "feedID", feedID))
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/server/core"
|
||||
"github.com/miniflux/miniflux/server/ui/form"
|
||||
|
||||
|
@ -36,13 +36,13 @@ func (c *Controller) CheckLogin(ctx *core.Context, request *core.Request, respon
|
|||
}
|
||||
|
||||
if err := authForm.Validate(); err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:CheckLogin] %v", err)
|
||||
response.HTML().Render("login", tplParams)
|
||||
return
|
||||
}
|
||||
|
||||
if err := c.store.CheckPassword(authForm.Username, authForm.Password); err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:CheckLogin] %v", err)
|
||||
response.HTML().Render("login", tplParams)
|
||||
return
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ func (c *Controller) CheckLogin(ctx *core.Context, request *core.Request, respon
|
|||
return
|
||||
}
|
||||
|
||||
log.Printf("[UI:CheckLogin] username=%s just logged in\n", authForm.Username)
|
||||
logger.Info("[Controller:CheckLogin] username=%s just logged in", authForm.Username)
|
||||
|
||||
cookie := &http.Cookie{
|
||||
Name: "sessionID",
|
||||
|
@ -78,7 +78,7 @@ func (c *Controller) Logout(ctx *core.Context, request *core.Request, response *
|
|||
|
||||
sessionCookie := request.Cookie("sessionID")
|
||||
if err := c.store.RemoveSessionByToken(user.ID, sessionCookie); err != nil {
|
||||
log.Printf("[UI:Logout] %v", err)
|
||||
logger.Error("[Controller:Logout] %v", err)
|
||||
}
|
||||
|
||||
cookie := &http.Cookie{
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/miniflux/miniflux/config"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/server/core"
|
||||
"github.com/miniflux/miniflux/server/oauth2"
|
||||
|
@ -19,14 +19,14 @@ import (
|
|||
func (c *Controller) OAuth2Redirect(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
provider := request.StringParam("provider", "")
|
||||
if provider == "" {
|
||||
log.Println("[OAuth2] Invalid or missing provider")
|
||||
logger.Error("[OAuth2] Invalid or missing provider")
|
||||
response.Redirect(ctx.Route("login"))
|
||||
return
|
||||
}
|
||||
|
||||
authProvider, err := getOAuth2Manager(c.cfg).Provider(provider)
|
||||
if err != nil {
|
||||
log.Println("[OAuth2]", err)
|
||||
logger.Error("[OAuth2] %v", err)
|
||||
response.Redirect(ctx.Route("login"))
|
||||
return
|
||||
}
|
||||
|
@ -38,35 +38,35 @@ func (c *Controller) OAuth2Redirect(ctx *core.Context, request *core.Request, re
|
|||
func (c *Controller) OAuth2Callback(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
provider := request.StringParam("provider", "")
|
||||
if provider == "" {
|
||||
log.Println("[OAuth2] Invalid or missing provider")
|
||||
logger.Error("[OAuth2] Invalid or missing provider")
|
||||
response.Redirect(ctx.Route("login"))
|
||||
return
|
||||
}
|
||||
|
||||
code := request.QueryStringParam("code", "")
|
||||
if code == "" {
|
||||
log.Println("[OAuth2] No code received on callback")
|
||||
logger.Error("[OAuth2] No code received on callback")
|
||||
response.Redirect(ctx.Route("login"))
|
||||
return
|
||||
}
|
||||
|
||||
state := request.QueryStringParam("state", "")
|
||||
if state != ctx.CsrfToken() {
|
||||
log.Println("[OAuth2] Invalid state value")
|
||||
logger.Error("[OAuth2] Invalid state value")
|
||||
response.Redirect(ctx.Route("login"))
|
||||
return
|
||||
}
|
||||
|
||||
authProvider, err := getOAuth2Manager(c.cfg).Provider(provider)
|
||||
if err != nil {
|
||||
log.Println("[OAuth2]", err)
|
||||
logger.Error("[OAuth2] %v", err)
|
||||
response.Redirect(ctx.Route("login"))
|
||||
return
|
||||
}
|
||||
|
||||
profile, err := authProvider.GetProfile(code)
|
||||
if err != nil {
|
||||
log.Println("[OAuth2]", err)
|
||||
logger.Error("[OAuth2] %v", err)
|
||||
response.Redirect(ctx.Route("login"))
|
||||
return
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ func (c *Controller) OAuth2Callback(ctx *core.Context, request *core.Request, re
|
|||
return
|
||||
}
|
||||
|
||||
log.Printf("[UI:OAuth2Callback] username=%s just logged in\n", user.Username)
|
||||
logger.Info("[Controller:OAuth2Callback] username=%s just logged in", user.Username)
|
||||
|
||||
cookie := &http.Cookie{
|
||||
Name: "sessionID",
|
||||
|
@ -134,14 +134,14 @@ func (c *Controller) OAuth2Callback(ctx *core.Context, request *core.Request, re
|
|||
func (c *Controller) OAuth2Unlink(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
provider := request.StringParam("provider", "")
|
||||
if provider == "" {
|
||||
log.Println("[OAuth2] Invalid or missing provider")
|
||||
logger.Info("[OAuth2] Invalid or missing provider")
|
||||
response.Redirect(ctx.Route("login"))
|
||||
return
|
||||
}
|
||||
|
||||
authProvider, err := getOAuth2Manager(c.cfg).Provider(provider)
|
||||
if err != nil {
|
||||
log.Println("[OAuth2]", err)
|
||||
logger.Error("[OAuth2] %v", err)
|
||||
response.Redirect(ctx.Route("settings"))
|
||||
return
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/server/core"
|
||||
)
|
||||
|
||||
|
@ -39,14 +38,19 @@ func (c *Controller) Import(ctx *core.Context, request *core.Request, response *
|
|||
func (c *Controller) UploadOPML(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
file, fileHeader, err := request.File("file")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:UploadOPML] %v", err)
|
||||
response.Redirect(ctx.Route("import"))
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
user := ctx.LoggedUser()
|
||||
log.Printf("[UI:UploadOPML] User #%d uploaded this file: %s (%d bytes)\n", user.ID, fileHeader.Filename, fileHeader.Size)
|
||||
logger.Info(
|
||||
"[Controller:UploadOPML] User #%d uploaded this file: %s (%d bytes)",
|
||||
user.ID,
|
||||
fileHeader.Filename,
|
||||
fileHeader.Size,
|
||||
)
|
||||
|
||||
if impErr := c.opmlHandler.Import(user.ID, file); impErr != nil {
|
||||
args, err := c.getCommonTemplateArgs(ctx)
|
||||
|
|
|
@ -8,11 +8,11 @@ import (
|
|||
"encoding/base64"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/helper"
|
||||
"github.com/miniflux/miniflux/http"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/server/core"
|
||||
)
|
||||
|
||||
|
@ -39,7 +39,7 @@ func (c *Controller) ImageProxy(ctx *core.Context, request *core.Request, respon
|
|||
client := http.NewClient(string(decodedURL))
|
||||
resp, err := client.Get()
|
||||
if err != nil {
|
||||
log.Println("[ImageProxy]", err)
|
||||
logger.Error("[Controller:ImageProxy] %v", err)
|
||||
response.HTML().NotFound()
|
||||
return
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/server/core"
|
||||
)
|
||||
|
||||
|
@ -45,7 +44,7 @@ func (c *Controller) RemoveSession(ctx *core.Context, request *core.Request, res
|
|||
|
||||
err = c.store.RemoveSessionByID(user.ID, sessionID)
|
||||
if err != nil {
|
||||
log.Println("[UI:RemoveSession]", err)
|
||||
logger.Error("[Controller:RemoveSession] %v", err)
|
||||
}
|
||||
|
||||
response.Redirect(ctx.Route("sessions"))
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux/locale"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/server/core"
|
||||
"github.com/miniflux/miniflux/server/ui/form"
|
||||
|
@ -55,7 +54,7 @@ func (c *Controller) UpdateSettings(ctx *core.Context, request *core.Request, re
|
|||
|
||||
err = c.store.UpdateUser(settingsForm.Merge(user))
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:UpdateSettings] %v", err)
|
||||
response.HTML().Render("settings", args.Merge(tplParams{
|
||||
"form": settingsForm,
|
||||
"errorMessage": "Unable to update this user.",
|
||||
|
|
|
@ -6,9 +6,9 @@ package controller
|
|||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/server/core"
|
||||
"github.com/miniflux/miniflux/server/static"
|
||||
)
|
||||
|
@ -36,7 +36,7 @@ func (c *Controller) Javascript(ctx *core.Context, request *core.Request, respon
|
|||
func (c *Controller) Favicon(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
blob, err := base64.StdEncoding.DecodeString(static.Binaries["favicon.ico"])
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:Favicon] %v", err)
|
||||
response.HTML().NotFound()
|
||||
return
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/reader/subscription"
|
||||
"github.com/miniflux/miniflux/server/core"
|
||||
|
@ -62,7 +61,7 @@ func (c *Controller) SubmitSubscription(ctx *core.Context, request *core.Request
|
|||
|
||||
subscriptions, err := subscription.FindSubscriptions(subscriptionForm.URL)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:SubmitSubscription] %v", err)
|
||||
response.HTML().Render("add_subscription", args.Merge(tplParams{
|
||||
"form": subscriptionForm,
|
||||
"errorMessage": err,
|
||||
|
@ -70,7 +69,7 @@ func (c *Controller) SubmitSubscription(ctx *core.Context, request *core.Request
|
|||
return
|
||||
}
|
||||
|
||||
log.Println("[UI:SubmitSubscription]", subscriptions)
|
||||
logger.Info("[UI:SubmitSubscription] %s", subscriptions)
|
||||
|
||||
n := len(subscriptions)
|
||||
switch {
|
||||
|
|
|
@ -6,8 +6,8 @@ package controller
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/server/core"
|
||||
"github.com/miniflux/miniflux/server/ui/form"
|
||||
|
@ -97,7 +97,7 @@ func (c *Controller) SaveUser(ctx *core.Context, request *core.Request, response
|
|||
|
||||
newUser := userForm.ToUser()
|
||||
if err := c.store.CreateUser(newUser); err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:SaveUser] %v", err)
|
||||
response.HTML().Render("edit_user", args.Merge(tplParams{
|
||||
"menu": "settings",
|
||||
"form": userForm,
|
||||
|
@ -182,7 +182,7 @@ func (c *Controller) UpdateUser(ctx *core.Context, request *core.Request, respon
|
|||
|
||||
userForm.Merge(selectedUser)
|
||||
if err := c.store.UpdateUser(selectedUser); err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Controller:UpdateUser] %v", err)
|
||||
response.HTML().Render("edit_user", args.Merge(tplParams{
|
||||
"menu": "settings",
|
||||
"selected_user": selectedUser,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2017-12-12 21:44:02.647917692 -0800 PST m=+0.002328395
|
||||
// 2017-12-15 18:49:24.029844239 -0800 PST m=+0.002440111
|
||||
|
||||
package sql
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ package storage
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/helper"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
@ -137,7 +137,7 @@ func (s *Storage) UpdateEntries(userID, feedID int64, entries model.Entries) (er
|
|||
}
|
||||
|
||||
if err := s.CleanupEntries(feedID, entryHashes); err != nil {
|
||||
log.Println(err)
|
||||
logger.Error("[Storage:CleanupEntries] %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -68,9 +68,9 @@ func (s *Storage) Integration(userID int64) (*model.Integration, error) {
|
|||
)
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
return nil, nil
|
||||
return &integration, nil
|
||||
case err != nil:
|
||||
return nil, fmt.Errorf("unable to fetch integration row: %v", err)
|
||||
return &integration, fmt.Errorf("unable to fetch integration row: %v", err)
|
||||
}
|
||||
|
||||
return &integration, nil
|
||||
|
|
|
@ -6,9 +6,9 @@ package storage
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/sql"
|
||||
)
|
||||
|
||||
|
@ -27,7 +27,7 @@ func (s *Storage) Migrate() {
|
|||
|
||||
tx, err := s.db.Begin()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
logger.Fatal("[Storage:Migrate] %v", err)
|
||||
}
|
||||
|
||||
rawSQL := sql.SqlMap["schema_version_"+strconv.Itoa(version)]
|
||||
|
@ -35,21 +35,21 @@ func (s *Storage) Migrate() {
|
|||
_, err = tx.Exec(rawSQL)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
log.Fatalln(err)
|
||||
logger.Fatal("[Storage:Migrate] %v", err)
|
||||
}
|
||||
|
||||
if _, err := tx.Exec(`delete from schema_version`); err != nil {
|
||||
tx.Rollback()
|
||||
log.Fatalln(err)
|
||||
logger.Fatal("[Storage:Migrate] %v", err)
|
||||
}
|
||||
|
||||
if _, err := tx.Exec(`insert into schema_version (version) values($1)`, version); err != nil {
|
||||
tx.Rollback()
|
||||
log.Fatalln(err)
|
||||
logger.Fatal("[Storage:Migrate] %v", err)
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
log.Fatalln(err)
|
||||
logger.Fatal("[Storage:Migrate] %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ package storage
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"log"
|
||||
|
||||
// Postgresql driver import
|
||||
_ "github.com/lib/pq"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
)
|
||||
|
||||
// Storage handles all operations related to the database.
|
||||
|
@ -26,7 +26,7 @@ func (s *Storage) Close() {
|
|||
func NewStorage(databaseURL string, maxOpenConns int) *Storage {
|
||||
db, err := sql.Open("postgres", databaseURL)
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to connect to the database: %v", err)
|
||||
logger.Fatal("[Storage] Unable to connect to the database: %v", err)
|
||||
}
|
||||
|
||||
db.SetMaxOpenConns(maxOpenConns)
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -113,7 +112,7 @@ func (s *Storage) RemoveExtraField(userID int64, field string) error {
|
|||
// UpdateUser updates a user.
|
||||
func (s *Storage) UpdateUser(user *model.User) error {
|
||||
defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:UpdateUser] userID=%d", user.ID))
|
||||
log.Println(user.EntryDirection)
|
||||
|
||||
if user.Password != "" {
|
||||
hashedPassword, err := hashPassword(user.Password)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue