Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dtu-enote-website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
enote
dtu-enote-website
Commits
741e232a
Commit
741e232a
authored
6 years ago
by
iaibrys
Browse files
Options
Downloads
Patches
Plain Diff
Add user to logging.
parent
aecfc4e5
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#165
passed
6 years ago
Stage: build
Stage: test
Stage: release
Stage: deploy
Changes
3
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
config/application.rb
+25
-9
25 additions, 9 deletions
config/application.rb
config/environments/production.rb
+13
-1
13 additions, 1 deletion
config/environments/production.rb
deps/dtu-core
+1
-1
1 addition, 1 deletion
deps/dtu-core
with
39 additions
and
11 deletions
config/application.rb
+
25
−
9
View file @
741e232a
...
...
@@ -17,6 +17,15 @@ require 'rails/test_unit/railtie'
# you've limited to :test, :development, or :production.
Bundler
.
require
(
*
Rails
.
groups
)
# Simple formatter which only displays the message.
class
EnoteFormatter
<
::
Logger
::
Formatter
# This method is invoked when a log event occurs
def
call
(
severity
,
timestamp
,
progname
,
msg
)
# Format % [severity[0..0], format_datetime(timestamp), $$, severity, progname, msg2str(msg)]
"
#{
severity
[
0
..
0
]
}
[
#{
format_datetime
(
timestamp
)
}
]
#{
msg2str
(
msg
)
}
\n
"
end
end
module
DTUCourseWebsite
##
# Application
...
...
@@ -41,7 +50,8 @@ module DTUCourseWebsite
# add service objects
config
.
autoload_paths
+=
Dir
[
"
#{
config
.
root
}
/app/services/**/"
]
config
.
autoload_paths
+=
Dir
[
"
#{
config
.
root
}
/app/responders/**/"
]
config
.
autoload_paths
+=
Dir
[
"
#{
config
.
root
}
/lib**/"
]
config
.
autoload_paths
+=
Dir
[
"
#{
config
.
root
}
/lib/**/"
]
config
.
eager_load_paths
+=
Dir
[
"
#{
config
.
root
}
/lib/**/"
]
DtuCore
::
app_init
config
...
...
@@ -54,17 +64,23 @@ module DTUCourseWebsite
g
.
test_framework
:rspec
end
log_level
=
String
(
ENV
.
fetch
(
'LOG_LEVEL'
)
{
config
.
deployment_environment
[
:public_facing
]
?
'info'
:
'debug'
}).
upcase
config
.
logger
=
Logger
.
new
(
STDOUT
)
config
.
logger
.
level
=
Logger
.
const_get
(
log_level
)
config
.
log_level
=
log_level
logger
=
ActiveSupport
::
Logger
.
new
(
STDOUT
)
logger
.
formatter
=
EnoteFormatter
.
new
#config.log_formatter
config
.
logger
=
ActiveSupport
::
TaggedLogging
.
new
(
logger
)
config
.
lograge
.
enabled
=
true
# log rage doesn't log params by default, so add this to do so.
unless
Rails
.
env
.
production?
# log rage doesn't log params by default.
# For production, though, the params can be HUGE (e.g. webgazer datapoints, so let's be cautious)
config
.
lograge
.
custom_options
=
lambda
do
|
event
|
exceptions
=
%w[controller action format id]
{
params:
event
.
payload
[
:params
].
except
(
*
exceptions
)
}
exceptions
=
%w[controller action format id points]
{
params:
event
.
payload
[
:params
].
except
(
*
exceptions
),
time:
event
.
time
}
end
end
if
config
.
lograge
.
enabled
class
ActionDispatch::DebugExceptions
alias
old_log_error
log_error
...
...
This diff is collapsed.
Click to expand it.
config/environments/production.rb
+
13
−
1
View file @
741e232a
...
...
@@ -49,7 +49,19 @@ Rails.application.configure do
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config
.
log_level
=
config
.
deployment_environment
[
:public_facing
]
?
:info
:
:debug
config
.
log_level
=
String
(
ENV
.
fetch
(
'LOG_LEVEL'
)
{
config
.
deployment_environment
[
:public_facing
]
?
'info'
:
'debug'
}).
upcase
# Prepend all log lines with the following tags.
config
.
log_tags
=
[
:request_id
,
# http://blog.simontaranto.com/post/2018-05-18-better-rails-logs-current-user-request-context.html/
->
(
req
){
if
user_id
=
CasTaggedLogger
.
extract_user_id_from_request
(
req
)
user_id
.
to_s
else
"?"
end
}
]
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
...
...
This diff is collapsed.
Click to expand it.
dtu-core
@
47843224
Compare
601f75c4
...
47843224
Subproject commit
601f75c4374ceceae3ba57e2f8bb5a9d81e658d2
Subproject commit
4784322436b2411c8f15c1a1366aa13ffd59bb55
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment