Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-workhorse
Commits
7e5084eb
Commit
7e5084eb
authored
Jan 13, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forgot to commit moved logging.go
parent
d360a0c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
internal/helper/logging.go
internal/helper/logging.go
+52
-0
No files found.
internal/helper/logging.go
0 → 100644
View file @
7e5084eb
package
helper
import
(
"fmt"
"net/http"
"time"
)
type
LoggingResponseWriter
struct
{
rw
http
.
ResponseWriter
status
int
written
int64
started
time
.
Time
}
func
NewLoggingResponseWriter
(
rw
http
.
ResponseWriter
)
LoggingResponseWriter
{
return
LoggingResponseWriter
{
rw
:
rw
,
started
:
time
.
Now
(),
}
}
func
(
l
*
LoggingResponseWriter
)
Header
()
http
.
Header
{
return
l
.
rw
.
Header
()
}
func
(
l
*
LoggingResponseWriter
)
Write
(
data
[]
byte
)
(
n
int
,
err
error
)
{
if
l
.
status
==
0
{
l
.
WriteHeader
(
http
.
StatusOK
)
}
n
,
err
=
l
.
rw
.
Write
(
data
)
l
.
written
+=
int64
(
n
)
return
}
func
(
l
*
LoggingResponseWriter
)
WriteHeader
(
status
int
)
{
if
l
.
status
!=
0
{
return
}
l
.
status
=
status
l
.
rw
.
WriteHeader
(
status
)
}
func
(
l
*
LoggingResponseWriter
)
Log
(
r
*
http
.
Request
)
{
duration
:=
time
.
Since
(
l
.
started
)
fmt
.
Printf
(
"%s %s - - [%s] %q %d %d %q %q %f
\n
"
,
r
.
Host
,
r
.
RemoteAddr
,
l
.
started
,
fmt
.
Sprintf
(
"%s %s %s"
,
r
.
Method
,
r
.
RequestURI
,
r
.
Proto
),
l
.
status
,
l
.
written
,
r
.
Referer
(),
r
.
UserAgent
(),
duration
.
Seconds
(),
)
}
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