rails-flog 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +5 -4
- data/Rakefile +1 -0
- data/lib/flog/params_formattable.rb +2 -3
- data/lib/flog/version.rb +1 -1
- data/test/test_helper.rb +2 -2
- data/test/unit/params_formattable_test.rb +2 -2
- data/test/unit/sql_formattable_test.rb +17 -24
- data/test/unit/status_test.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fbf46665254484f9fb2fcf9d209b46a8303e028
|
4
|
+
data.tar.gz: b2bdd9a21547bf84cbbbba6ebd7d54dc5baef4e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d737e91d22762f40a7b0b08e844408f92e8c17879e985ec07555c5eda8608650042770e1f6c5ab1c54f023c258753a22efa95a7defca591a0e6e45b589155556
|
7
|
+
data.tar.gz: 67d28e57171f04d269539e8405e874eff4c35e7ba80596a8e8484c03903a5ca987d3373f94a3b5ee8c36be7289dd40e78d0fee93c3ba8cfba546065e3c06d1ce
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
rails-flog provides feature that formats parameters Hash and SQL in Rails log file.
|
7
7
|
|
8
|
-
## Before and after (
|
8
|
+
## Before and after (Sample app: Redmine)
|
9
9
|
|
10
10
|
### Before (Default)
|
11
11
|
|
@@ -99,7 +99,7 @@ Flog.configure do |config|
|
|
99
99
|
config.query_duration_threshold = 2.0
|
100
100
|
# If key count of parameters is under this value, not format
|
101
101
|
config.params_key_count_threshold = 2
|
102
|
-
# If this value is true,
|
102
|
+
# If this value is true, nested Hash parameter is formatted coercively in any situation
|
103
103
|
config.force_on_nested_params = false
|
104
104
|
end
|
105
105
|
```
|
@@ -115,7 +115,7 @@ end
|
|
115
115
|
|
116
116
|
## Disable temporary
|
117
117
|
|
118
|
-
If you put a file to `<rails_app>/tmp` direcotry, `rails-flog` will disable format.
|
118
|
+
If you put a file to `<rails_app>/tmp` direcotry, `rails-flog` will disable format.
|
119
119
|
Priority of this feature is higher than configurations.
|
120
120
|
|
121
121
|
|File name |Feature |
|
@@ -127,7 +127,7 @@ Priority of this feature is higher than configurations.
|
|
127
127
|
## Supported versions
|
128
128
|
|
129
129
|
- Ruby: 1.9.3, 2.0.0, 2.1.0
|
130
|
-
- Rails: 3.2.x, 4.0.x
|
130
|
+
- Rails: 3.2.x, 4.0.x, 4.1.x
|
131
131
|
|
132
132
|
## Contributing
|
133
133
|
|
@@ -145,3 +145,4 @@ Priority of this feature is higher than configurations.
|
|
145
145
|
- v1.2.0 (2014-01-14 JST): Add feature that disables format partially by no-flog-sql.txt and no-flog-params.txt
|
146
146
|
- v1.3.0 (2014-01-26 JST): Add configuration
|
147
147
|
- v1.3.1 (2014-01-27 JST): Refactored
|
148
|
+
- v1.3.2 (2014-04-28 JST): Confirm with Rails 4.1
|
data/Rakefile
CHANGED
@@ -54,8 +54,7 @@ class ActionController::LogSubscriber
|
|
54
54
|
|
55
55
|
def key_count_over?(event)
|
56
56
|
threshold = Flog.config.params_key_count_threshold.to_i
|
57
|
-
|
58
|
-
|
59
|
-
event.payload[:params].keys.size > threshold
|
57
|
+
params = event.payload[:params].except(*INTERNAL_PARAMS)
|
58
|
+
params.keys.size > threshold
|
60
59
|
end
|
61
60
|
end
|
data/lib/flog/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -68,7 +68,7 @@ class ParamsFormattableTest < ActionController::TestCase
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def test_parameters_log_is_not_formatted_when_enabled_is_false
|
71
|
-
Flog::Status.
|
71
|
+
Flog::Status.stubs(:enabled?).returns(false)
|
72
72
|
get :show, foo: "foo_value", bar: "bar_value"
|
73
73
|
assert_logger do |logger|
|
74
74
|
assert logger.infos[1].include?(%(Parameters: {"foo"=>"foo_value", "bar"=>"bar_value"}))
|
@@ -76,7 +76,7 @@ class ParamsFormattableTest < ActionController::TestCase
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def test_parameters_log_is_not_formatted_when_params_formattable_is_false
|
79
|
-
Flog::Status.
|
79
|
+
Flog::Status.stubs(:params_formattable?).returns(false)
|
80
80
|
get :show, foo: "foo_value", bar: "bar_value"
|
81
81
|
assert_logger do |logger|
|
82
82
|
assert logger.infos[1].include?(%(Parameters: {"foo"=>"foo_value", "bar"=>"bar_value"}))
|
@@ -59,18 +59,18 @@ class SqlFormattableTest < ActiveSupport::TestCase
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_sql_is_not_formatted_when_enabled_is_false
|
62
|
-
Flog::Status.
|
62
|
+
Flog::Status.stubs(:enabled?).returns(false)
|
63
63
|
Book.where(category: "comics").to_a
|
64
64
|
assert_logger do |logger|
|
65
|
-
|
65
|
+
assert_one_line_sql logger.debugs.first
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_sql_is_not_formatted_when_sql_formattable_is_false
|
70
|
-
Flog::Status.
|
70
|
+
Flog::Status.stubs(:sql_formattable?).returns(false)
|
71
71
|
Book.where(category: "comics").to_a
|
72
72
|
assert_logger do |logger|
|
73
|
-
|
73
|
+
assert_one_line_sql logger.debugs.first
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -81,13 +81,9 @@ class SqlFormattableTest < ActiveSupport::TestCase
|
|
81
81
|
end
|
82
82
|
assert_logger do |logger|
|
83
83
|
logs = logger.debugs.map { |log| log.gsub("\t", " ") }
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
assert_equal %{ "books"} , logs[4]
|
88
|
-
assert_equal %{ WHERE} , logs[5]
|
89
|
-
assert_equal %{ "books" . "category" = 'comics'}, logs[6]
|
90
|
-
assert logs[7].include?(%(SELECT "books".* FROM "books" WHERE "books"."category" = 'comics'))
|
84
|
+
logs.each do |log|
|
85
|
+
assert_one_line_sql log if log.include?("CACHE")
|
86
|
+
end
|
91
87
|
end
|
92
88
|
end
|
93
89
|
|
@@ -101,18 +97,9 @@ class SqlFormattableTest < ActiveSupport::TestCase
|
|
101
97
|
end
|
102
98
|
assert_logger do |logger|
|
103
99
|
logs = logger.debugs.map { |log| log.gsub("\t", " ") }
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
assert_equal %{ "books"} , logs[4]
|
108
|
-
assert_equal %{ WHERE} , logs[5]
|
109
|
-
assert_equal %{ "books" . "category" = 'comics'}, logs[6]
|
110
|
-
assert_equal %{ SELECT} , logs[8]
|
111
|
-
assert_equal %{ "books" . *} , logs[9]
|
112
|
-
assert_equal %{ FROM} , logs[10]
|
113
|
-
assert_equal %{ "books"} , logs[11]
|
114
|
-
assert_equal %{ WHERE} , logs[12]
|
115
|
-
assert_equal %{ "books" . "category" = 'comics'}, logs[13]
|
100
|
+
logs.each do |log|
|
101
|
+
assert_equal log.include?("SELECT"), false if log.include?("CACHE")
|
102
|
+
end
|
116
103
|
end
|
117
104
|
end
|
118
105
|
|
@@ -122,7 +109,7 @@ class SqlFormattableTest < ActiveSupport::TestCase
|
|
122
109
|
end
|
123
110
|
Book.where(category: "comics").to_a
|
124
111
|
assert_logger do |logger|
|
125
|
-
|
112
|
+
assert_one_line_sql logger.debugs.first
|
126
113
|
end
|
127
114
|
end
|
128
115
|
|
@@ -134,4 +121,10 @@ class SqlFormattableTest < ActiveSupport::TestCase
|
|
134
121
|
block.call(ActiveRecord::Base.logger)
|
135
122
|
end
|
136
123
|
end
|
124
|
+
|
125
|
+
def assert_one_line_sql(sql)
|
126
|
+
assert sql.include?("SELECT")
|
127
|
+
assert sql.include?("FROM")
|
128
|
+
assert sql.include?("WHERE")
|
129
|
+
end
|
137
130
|
end
|
data/test/unit/status_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-flog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pinzolo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
173
|
version: '0'
|
174
174
|
requirements: []
|
175
175
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.0.
|
176
|
+
rubygems_version: 2.0.14
|
177
177
|
signing_key:
|
178
178
|
specification_version: 4
|
179
179
|
summary: Rails log formatter for parameters and sql
|