BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
9bc176b2
Commit
9bc176b2
authored
Jul 28, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add remote IP, user ID and username to JSON lograge output
This makes the logs a bit more useful to search requests by users.
parent
02b25598
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
application_controller.rb
app/controllers/application_controller.rb
+10
-0
lograge.rb
config/initializers/lograge.rb
+4
-1
No files found.
app/controllers/application_controller.rb
View file @
9bc176b2
...
@@ -70,6 +70,16 @@ class ApplicationController < ActionController::Base
...
@@ -70,6 +70,16 @@ class ApplicationController < ActionController::Base
protected
protected
def
append_info_to_payload
(
payload
)
super
payload
[
:remote_ip
]
=
request
.
remote_ip
if
current_user
.
present?
payload
[
:user_id
]
=
current_user
.
id
payload
[
:username
]
=
current_user
.
username
end
end
# This filter handles both private tokens and personal access tokens
# This filter handles both private tokens and personal access tokens
def
authenticate_user_from_private_token!
def
authenticate_user_from_private_token!
token
=
params
[
:private_token
].
presence
||
request
.
headers
[
'PRIVATE-TOKEN'
].
presence
token
=
params
[
:private_token
].
presence
||
request
.
headers
[
'PRIVATE-TOKEN'
].
presence
...
...
config/initializers/lograge.rb
View file @
9bc176b2
...
@@ -14,7 +14,10 @@ unless Sidekiq.server?
...
@@ -14,7 +14,10 @@ unless Sidekiq.server?
config
.
lograge
.
custom_options
=
lambda
do
|
event
|
config
.
lograge
.
custom_options
=
lambda
do
|
event
|
{
{
time:
event
.
time
.
utc
.
iso8601
(
3
),
time:
event
.
time
.
utc
.
iso8601
(
3
),
params:
event
.
payload
[
:params
].
except
(
%w(controller action format)
)
params:
event
.
payload
[
:params
].
except
(
*
%w(controller action format)
),
remote_ip:
event
.
payload
[
:remote_ip
],
user_id:
event
.
payload
[
:user_id
],
username:
event
.
payload
[
:username
]
}
}
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