custom_logs 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjliY2M4Mjg4MGEwZjg3MDE2NWM0MmQ3NTIxYmUxYTk1MjM0MDAyOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWJjNTU3NjJlYmYwZWZkNWU2ZWYyM2I5YWZlMDgyNWM2MzcxNjQ3NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODc3YzkxYTU0NzgwMTczNzE2MjNlZDlkOTllYTEwMDcyOGEzODg5MjI1Mzll
|
10
|
+
MzY4MjJmM2M1N2E5NWYyYjNmZGQ3Njg3NGNkMzk0MjU5YzVlMDg4MmYxN2Q0
|
11
|
+
YzZlMjI0ZDA0NTU4OTgyMTVlZjQ2OGJhZjA5ZDdmOTA3YmU4N2I=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTBlM2RjMTBmNzU3NDQ3ZTM0ZWY2MWIzYTg5Nzc5NGFiMzZkOTBjZGY4ZTY0
|
14
|
+
OTY5NzNmMDdkYzI2NGRjOWQ3YTVjMDgxNzYxOWE3Njk2ZmFlMjdkYTAyMmZi
|
15
|
+
YjFjMmZiMjU0YTc0YzU4MDM5MjU5ZjA1ZDFjODAwYzA4OGMwMGM=
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module CustomLogs
|
2
2
|
module ActionControllerExt
|
3
3
|
|
4
|
+
protected
|
5
|
+
|
4
6
|
def custom_logs
|
5
7
|
|
6
8
|
original_params = get_original_params
|
@@ -12,12 +14,18 @@ module CustomLogs
|
|
12
14
|
logs = {
|
13
15
|
controller: params[:controller],
|
14
16
|
action: params[:action],
|
15
|
-
|
17
|
+
current: try_current_user_email,
|
18
|
+
path: request.path,
|
16
19
|
params: original_params
|
17
20
|
#flash: original_flash,
|
18
21
|
#response_code: response.status,
|
19
22
|
#response_message: response.message
|
20
23
|
}
|
24
|
+
|
25
|
+
if request.xhr?
|
26
|
+
logs[:ajax] = ajax_attributes
|
27
|
+
end
|
28
|
+
|
21
29
|
CustomLogs::Logger.write(logs)
|
22
30
|
rescue
|
23
31
|
Rails.logger.info "[CUSTOM LOGS NOT SAVED]: #{logs.to_json}"
|
@@ -26,10 +34,6 @@ module CustomLogs
|
|
26
34
|
|
27
35
|
end
|
28
36
|
|
29
|
-
def try_current_user_email
|
30
|
-
current_user.email rescue ''
|
31
|
-
end
|
32
|
-
|
33
37
|
def get_original_params
|
34
38
|
path_params = request.path_parameters
|
35
39
|
request.params.clone.except(*path_params.keys)
|
@@ -39,5 +43,22 @@ module CustomLogs
|
|
39
43
|
request.flash.clone
|
40
44
|
end
|
41
45
|
|
46
|
+
def try_current_user_email
|
47
|
+
current = nil
|
48
|
+
ParseConfig.get[:user_methods].each do |user_method|
|
49
|
+
current = {:"#{user_method.gsub('current_', '')}" => send(user_method).email} rescue nil
|
50
|
+
break if current
|
51
|
+
end
|
52
|
+
current
|
53
|
+
end
|
54
|
+
|
55
|
+
def ajax_attributes
|
56
|
+
begin
|
57
|
+
{referer: URI::parse(request.headers["HTTP_REFERER"]).path}
|
58
|
+
rescue
|
59
|
+
{}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
42
63
|
end
|
43
64
|
end
|
data/lib/custom_logs/logger.rb
CHANGED
@@ -36,7 +36,8 @@ module CustomLogs
|
|
36
36
|
elsif value.instance_of? Hash
|
37
37
|
new_hash[key] = truncate_hash(value, length, truncate_value)
|
38
38
|
else
|
39
|
-
|
39
|
+
# we don't include key when value is not String
|
40
|
+
# new_hash[key] = truncate_value
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
data/lib/custom_logs/version.rb
CHANGED
@@ -7,4 +7,11 @@ class CustomLogsGenerator < Rails::Generators::Base
|
|
7
7
|
template "custom_logs.yml", 'config/custom_logs.yml'
|
8
8
|
end
|
9
9
|
|
10
|
+
private
|
11
|
+
|
12
|
+
def user_methods
|
13
|
+
user_methods = ApplicationController.new.methods.select{|m| m.to_s.starts_with?('current_')}
|
14
|
+
end
|
15
|
+
|
16
|
+
|
10
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_logs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Piechocki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|