Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
Léo-Paul Géneau
gitlab-ce
Commits
35dec2c3
Commit
35dec2c3
authored
Sep 07, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a custom GrapeLogging formatter to get the timestamp
parent
c304dfd4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
9 deletions
+21
-9
lib/api/api.rb
lib/api/api.rb
+2
-2
lib/gitlab/api_logger.rb
lib/gitlab/api_logger.rb
+0
-7
lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
...gitlab/grape_logging/formatters/lograge_with_timestamp.rb
+19
-0
No files found.
lib/api/api.rb
View file @
35dec2c3
...
@@ -5,8 +5,8 @@ module API
...
@@ -5,8 +5,8 @@ module API
LOG_FILENAME
=
Rails
.
root
.
join
(
"log"
,
"api_json.log"
)
LOG_FILENAME
=
Rails
.
root
.
join
(
"log"
,
"api_json.log"
)
use
GrapeLogging
::
Middleware
::
RequestLogger
,
use
GrapeLogging
::
Middleware
::
RequestLogger
,
logger:
::
Gitlab
::
Api
Logger
.
new
(
LOG_FILENAME
),
logger:
Logger
.
new
(
LOG_FILENAME
),
formatter:
G
rapeLogging
::
Formatters
::
Json
.
new
,
formatter:
G
itlab
::
GrapeLogging
::
Formatters
::
LogrageWithTimestamp
.
new
,
include:
[
include:
[
GrapeLogging
::
Loggers
::
Response
.
new
,
GrapeLogging
::
Loggers
::
Response
.
new
,
GrapeLogging
::
Loggers
::
FilterParameters
.
new
,
GrapeLogging
::
Loggers
::
FilterParameters
.
new
,
...
...
lib/gitlab/api_logger.rb
deleted
100644 → 0
View file @
c304dfd4
module
Gitlab
class
ApiLogger
<
::
Logger
def
format_message
(
severity
,
timestamp
,
progname
,
message
)
super
+
"
\n
"
end
end
end
lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
0 → 100644
View file @
35dec2c3
module
Gitlab
module
GrapeLogging
module
Formatters
class
LogrageWithTimestamp
def
call
(
severity
,
datetime
,
_
,
data
)
time
=
data
.
delete
:time
attributes
=
{
time:
datetime
.
utc
.
iso8601
(
3
),
severity:
severity
,
duration:
time
[
:total
],
db:
time
[
:db
],
view:
time
[
:view
]
}.
merge
(
data
)
::
Lograge
.
formatter
.
call
(
attributes
)
+
"
\n
"
end
end
end
end
end
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