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
1
Merge Requests
1
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
gitlab-ce
Commits
bf65ee5d
Commit
bf65ee5d
authored
Feb 13, 2020
by
Qingyu Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change OmniAuth log format to JSON
- Change OmniAuth log format to JSON - Keep only ERROR log in production
parent
d85a6b95
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
0 deletions
+34
-0
changelogs/unreleased/205184-change-omniauth-log-format-to-json.yml
.../unreleased/205184-change-omniauth-log-format-to-json.yml
+5
-0
config/initializers/omniauth.rb
config/initializers/omniauth.rb
+4
-0
lib/gitlab/omniauth_logging/json_formatter.rb
lib/gitlab/omniauth_logging/json_formatter.rb
+13
-0
spec/lib/gitlab/omniauth_logging/json_formatter_spec.rb
spec/lib/gitlab/omniauth_logging/json_formatter_spec.rb
+12
-0
No files found.
changelogs/unreleased/205184-change-omniauth-log-format-to-json.yml
0 → 100644
View file @
bf65ee5d
---
title
:
Change OmniAuth log format to JSON
merge_request
:
25086
author
:
type
:
other
config/initializers/omniauth.rb
View file @
bf65ee5d
...
...
@@ -16,3 +16,7 @@ OmniAuth.config.allowed_request_methods << :get if Gitlab.config.omniauth.auto_s
OmniAuth
.
config
.
before_request_phase
do
|
env
|
Gitlab
::
RequestForgeryProtection
.
call
(
env
)
end
# Use json formatter
OmniAuth
.
config
.
logger
.
formatter
=
Gitlab
::
OmniauthLogging
::
JSONFormatter
.
new
OmniAuth
.
config
.
logger
.
level
=
Logger
::
ERROR
if
Rails
.
env
.
production?
lib/gitlab/omniauth_logging/json_formatter.rb
0 → 100644
View file @
bf65ee5d
# frozen_string_literal: true
require
'json'
module
Gitlab
module
OmniauthLogging
class
JSONFormatter
def
call
(
severity
,
datetime
,
progname
,
msg
)
{
severity:
severity
,
timestamp:
datetime
.
utc
.
iso8601
(
3
),
pid:
$$
,
progname:
progname
,
message:
msg
}.
to_json
<<
"
\n
"
end
end
end
end
spec/lib/gitlab/omniauth_logging/json_formatter_spec.rb
0 → 100644
View file @
bf65ee5d
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
OmniauthLogging
::
JSONFormatter
do
it
"generates log in json format"
do
Timecop
.
freeze
(
Time
.
utc
(
2019
,
12
,
04
,
9
,
10
,
11
,
123456
))
do
expect
(
subject
.
call
(
:info
,
Time
.
now
,
'omniauth'
,
'log message'
))
.
to
eq
%Q({"severity":"info","timestamp":"2019-12-04T09:10:11.123Z","pid":
#{
Process
.
pid
}
,"progname":"omniauth","message":"log message"}
\n
)
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