Changed logging.
This commit is contained in:
parent
bde46d93b0
commit
7bd462d1d6
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"dwelling-upload/internal/configuration"
|
||||
"dwelling-upload/internal/handlers"
|
||||
"dwelling-upload/pkg/logging"
|
||||
"dwelling-upload/pkg/server"
|
||||
"flag"
|
||||
"log"
|
||||
@ -22,18 +23,34 @@ func main() {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
hand := handlers.NewUploadHandlers(config)
|
||||
logErr, err := logging.NewLogger(config.LogDir + "/error.log")
|
||||
if err != nil {
|
||||
log.Fatalln("failed to open error logger:", err)
|
||||
}
|
||||
defer logErr.Close()
|
||||
|
||||
logUpload, err := logging.NewLogger(config.LogDir + "/upload.log")
|
||||
if err != nil {
|
||||
log.Fatalln("failed to open upload logger:", err)
|
||||
}
|
||||
defer logUpload.Close()
|
||||
|
||||
logDownload, err := logging.NewLogger(config.LogDir + "/download.log")
|
||||
if err != nil {
|
||||
log.Fatalln("failed to open download logger:", err)
|
||||
}
|
||||
defer logDownload.Close()
|
||||
|
||||
hand := handlers.NewUploadHandlers(config, logErr, logUpload, logDownload)
|
||||
srv := server.NewHttpServer()
|
||||
|
||||
srv.ServeStatic("/assets/*filepath", http.Dir(config.WebDir+"/assets"))
|
||||
|
||||
srv.GET("/", hand.Index)
|
||||
srv.POST("/", hand.Upload)
|
||||
srv.GET("/f/:hash/:name", hand.Download)
|
||||
|
||||
if err := srv.Start(config.SplitNetworkAddress()); err != nil {
|
||||
log.Fatalln(err)
|
||||
logErr.Fatalln(err)
|
||||
}
|
||||
|
||||
doneSignal := make(chan os.Signal, 1)
|
||||
@ -42,6 +59,6 @@ func main() {
|
||||
<-doneSignal
|
||||
|
||||
if err := srv.Stop(); err != nil {
|
||||
log.Fatalln(err)
|
||||
logErr.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user