File tree Expand file tree Collapse file tree 4 files changed +38
-1
lines changed Expand file tree Collapse file tree 4 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 11source 'https://rubygems.org'
22git_source ( :github ) { |repo | "https://github.com/#{ repo } .git" }
3+ gem 'lograge'
4+ gem 'lograge-sql'
35
46ruby '2.3.3'
57gem 'knock' , github : 'psantos10/knock' , branch : 'master'
Original file line number Diff line number Diff line change 8080 rb-fsevent (~> 0.9 , >= 0.9.4 )
8181 rb-inotify (~> 0.9 , >= 0.9.7 )
8282 ruby_dep (~> 1.2 )
83+ lograge (0.11.2 )
84+ actionpack (>= 4 )
85+ activesupport (>= 4 )
86+ railties (>= 4 )
87+ request_store (~> 1.0 )
88+ lograge-sql (1.0.0 )
89+ activerecord (>= 4 , < 7.0 )
90+ lograge (~> 0.4 )
8391 loofah (2.2.3 )
8492 crass (~> 1.0.2 )
8593 nokogiri (>= 1.5.9 )
134142 rb-inotify (0.10.0 )
135143 ffi (~> 1.0 )
136144 rb-readline (0.5.5 )
145+ request_store (1.4.1 )
146+ rack (>= 1.4 )
137147 ruby_dep (1.5.0 )
138148 spring (2.0.2 )
139149 activesupport (>= 4.2 )
@@ -166,6 +176,8 @@ DEPENDENCIES
166176 jwt
167177 knock !
168178 listen (>= 3.0.5 , < 3.2 )
179+ lograge
180+ lograge-sql
169181 pg (>= 0.18 , < 2.0 )
170182 pry
171183 puma (~> 3.11 )
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ def index
88 end
99
1010 def get_current_user
11- jwt_token = request . headers [ 'HTTP_AUTHORIZATION' ]
11+ jwt_token = request . headers [ 'HTTP_AUTHORIZATION' ]
1212
1313 if jwt_token
1414 user_info = Auth . decode ( jwt_token )
@@ -17,4 +17,15 @@ def get_current_user
1717
1818 user
1919 end
20+ def append_info_to_payload ( payload )
21+ super
22+ case
23+ when payload [ :status ] == 200
24+ payload [ :level ] = "INFO"
25+ when payload [ :status ] == 302
26+ payload [ :level ] = "WARN"
27+ else
28+ payload [ :level ] = "ERROR"
29+ end
30+ end
2031 end
Original file line number Diff line number Diff line change 1+ require 'lograge/sql/extension'
2+
3+ Rails . application . configure do
4+ # Lograge config
5+ config . lograge . enabled = true
6+ config . lograge . formatter = Lograge ::Formatters ::Json . new
7+ config . colorize_logging = false
8+
9+ config . lograge . custom_options = lambda do |event |
10+ { :params => event . payload [ :params ] }
11+ end
12+ end
You can’t perform that action at this time.
0 commit comments