mirror of
https://github.com/vbatts/srvdav.git
synced 2024-11-22 08:35:40 +00:00
main: timestamp formatting in the log
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
178b63b13b
commit
a06aa900b7
1 changed files with 5 additions and 2 deletions
7
main.go
7
main.go
|
@ -8,6 +8,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/abbot/go-http-auth"
|
"github.com/abbot/go-http-auth"
|
||||||
"golang.org/x/net/webdav"
|
"golang.org/x/net/webdav"
|
||||||
|
@ -38,6 +39,8 @@ func main() {
|
||||||
FileSystem: fs,
|
FileSystem: fs,
|
||||||
LockSystem: webdav.NewMemLS(),
|
LockSystem: webdav.NewMemLS(),
|
||||||
Logger: func(r *http.Request, err error) {
|
Logger: func(r *http.Request, err error) {
|
||||||
|
t := time.Now()
|
||||||
|
tStamp := fmt.Sprintf("%d.%9.9d", t.Unix(), t.Nanosecond())
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "COPY", "MOVE":
|
case "COPY", "MOVE":
|
||||||
dst := ""
|
dst := ""
|
||||||
|
@ -45,9 +48,9 @@ func main() {
|
||||||
dst = u.Path
|
dst = u.Path
|
||||||
}
|
}
|
||||||
o := r.Header.Get("Overwrite")
|
o := r.Header.Get("Overwrite")
|
||||||
log.Printf("%-20s%-20s%-10s%-30s%-30so=%-2s%v", r.Header.Get("Date"), r.RemoteAddr, r.Method, r.URL.Path, dst, o, err)
|
log.Printf("%-21s%-25s%-10s%-30s%-30so=%-2s%v", tStamp, r.RemoteAddr, r.Method, r.URL.Path, dst, o, err)
|
||||||
default:
|
default:
|
||||||
log.Printf("%-20s%-20s%-10s%-30s%v", r.Header.Get("Date"), r.RemoteAddr, r.Method, r.URL.Path, err)
|
log.Printf("%-21s%-25s%-10s%-30s%v", tStamp, r.RemoteAddr, r.Method, r.URL.Path, err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue