mirror of
https://github.com/vbatts/srvdav.git
synced 2024-11-25 09:55: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"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/abbot/go-http-auth"
|
||||
"golang.org/x/net/webdav"
|
||||
|
@ -38,6 +39,8 @@ func main() {
|
|||
FileSystem: fs,
|
||||
LockSystem: webdav.NewMemLS(),
|
||||
Logger: func(r *http.Request, err error) {
|
||||
t := time.Now()
|
||||
tStamp := fmt.Sprintf("%d.%9.9d", t.Unix(), t.Nanosecond())
|
||||
switch r.Method {
|
||||
case "COPY", "MOVE":
|
||||
dst := ""
|
||||
|
@ -45,9 +48,9 @@ func main() {
|
|||
dst = u.Path
|
||||
}
|
||||
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:
|
||||
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