Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
71c4fdbc
Commit
71c4fdbc
authored
Jul 05, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
errors: Prepend timestamp to log entry
parent
7dbe4228
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
middleware/errors/errors.go
middleware/errors/errors.go
+4
-2
No files found.
middleware/errors/errors.go
View file @
71c4fdbc
...
...
@@ -9,6 +9,7 @@ import (
"os"
"runtime"
"strings"
"time"
"github.com/mholt/caddy/middleware"
)
...
...
@@ -27,7 +28,7 @@ func (h ErrorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, er
status
,
err
:=
h
.
Next
.
ServeHTTP
(
w
,
r
)
if
err
!=
nil
{
h
.
Log
.
Printf
(
"
[ERROR %d %s] %v"
,
status
,
r
.
URL
.
Path
,
err
)
h
.
Log
.
Printf
(
"
%s [ERROR %d %s] %v"
,
time
.
Now
()
.
Format
(
timeFormat
)
,
status
,
r
.
URL
.
Path
,
err
)
}
if
status
>=
400
{
...
...
@@ -107,8 +108,9 @@ func (h ErrorHandler) recovery(w http.ResponseWriter, r *http.Request) {
}
// Currently we don't use the function name, as file:line is more conventional
h
.
Log
.
Printf
(
"
[PANIC %s] %s:%d - %v"
,
r
.
URL
.
String
(),
file
,
line
,
rec
)
h
.
Log
.
Printf
(
"
%s [PANIC %s] %s:%d - %v"
,
time
.
Now
()
.
Format
(
timeFormat
)
,
r
.
URL
.
String
(),
file
,
line
,
rec
)
h
.
errorPage
(
w
,
http
.
StatusInternalServerError
)
}
const
DefaultLogFilename
=
"error.log"
const
timeFormat
=
"02/Jan/2006:15:04:05 -0700"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment