Closes micromata/swd#4
Inject logrus log writer to the default logger implementation
This commit is contained in:
parent
76c23dc14b
commit
c07f1c3dba
1 changed files with 14 additions and 4 deletions
|
@ -1,19 +1,29 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/micromata/swd/app"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/webdav"
|
||||
syslog "log"
|
||||
"net/http"
|
||||
"errors"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.SetFormatter(&log.TextFormatter{})
|
||||
|
||||
config := app.ParseConfig()
|
||||
|
||||
// Set formatter for logrus
|
||||
formatter := &log.TextFormatter{}
|
||||
log.SetFormatter(formatter)
|
||||
|
||||
// Set formatter for default log outputs
|
||||
logger := log.New()
|
||||
logger.Formatter = formatter
|
||||
writer := logger.Writer()
|
||||
defer writer.Close()
|
||||
syslog.SetOutput(writer)
|
||||
|
||||
wdHandler := &webdav.Handler{
|
||||
Prefix: config.Prefix,
|
||||
FileSystem: &app.Dir{
|
||||
|
@ -33,7 +43,6 @@ func main() {
|
|||
}
|
||||
|
||||
http.Handle("/", wrapRecovery(app.NewBasicAuthWebdavHandler(a)))
|
||||
|
||||
connAddr := fmt.Sprintf("%s:%s", config.Address, config.Port)
|
||||
|
||||
if config.TLS != nil {
|
||||
|
@ -43,6 +52,7 @@ func main() {
|
|||
"security": "TLS",
|
||||
}).Info("Server is starting and listening")
|
||||
log.Fatal(http.ListenAndServeTLS(connAddr, config.TLS.CertFile, config.TLS.KeyFile, nil))
|
||||
|
||||
} else {
|
||||
log.WithFields(log.Fields{
|
||||
"address": config.Address,
|
||||
|
|
Loading…
Reference in a new issue