summaryrefslogtreecommitdiff
path: root/app/app.go
diff options
context:
space:
mode:
authorJames Mills <prologic@shortcircuit.net.au>2020-03-21 21:11:42 +1000
committerJames Mills <prologic@shortcircuit.net.au>2020-03-21 21:11:42 +1000
commitcf096b9a1610e1a97075206250537346d5467bfb (patch)
tree206399c44663a4f869387e358cc1533ffefb5f67 /app/app.go
parent976a6b4a8c7bcdada5c52acc85f93ece4f91e667 (diff)
Add server logging
Diffstat (limited to 'app/app.go')
-rw-r--r--app/app.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/app.go b/app/app.go
index a17bab9..11bfb45 100644
--- a/app/app.go
+++ b/app/app.go
@@ -5,7 +5,6 @@ import (
"fmt"
"html/template"
"io"
- "log"
"net"
"net/http"
"os"
@@ -15,6 +14,7 @@ import (
rice "github.com/GeertJohan/go.rice"
"github.com/fsnotify/fsnotify"
"github.com/gorilla/mux"
+ log "github.com/sirupsen/logrus"
"github.com/wybiral/tube/media"
)
@@ -146,7 +146,6 @@ func (a *App) indexHandler(w http.ResponseWriter, r *http.Request) {
// HTTP handler for /upload
func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
- log.Printf("GET /upload")
ctx := &struct{}{}
a.render("upload", w, ctx)
} else if r.Method == "POST" {
@@ -156,6 +155,7 @@ func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) {
file, handler, err := r.FormFile("video_file")
if err != nil {
err := fmt.Errorf("error processing form: %w", err)
+ log.Error(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
@@ -168,6 +168,7 @@ func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) {
f, err := os.OpenFile(fn, os.O_RDWR|os.O_CREATE, 0755)
if err != nil {
err := fmt.Errorf("error opening file for writing: %w", err)
+ log.Error(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
@@ -176,6 +177,7 @@ func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) {
_, err = io.Copy(f, file)
if err != nil {
err := fmt.Errorf("error writing file: %w", err)
+ log.Error(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}