queryable_logs 0.1.4 → 0.1.5

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93f22e4779832fcc66336aa1efef9b7c018e0adeafef438bd802ad1d9b83ac25
4
- data.tar.gz: a292a1718893c1ea21b1426be847e5cd725d1af9e40b2e0a3a794ae9e487d287
3
+ metadata.gz: 90d56468738a68d4ebeedaeb45d91337678f6df8561e01317379b8b302af9d3d
4
+ data.tar.gz: 341a7b34f28255cd29a6c03af0c23d486c591cdbb46991d5c50d041bf6941b77
5
5
  SHA512:
6
- metadata.gz: 8026ce96cae28e076ab56ee4ba19fbc68de4cdc65af54cb8f3e92200b28773f5587610c248bea13a09c0f98ddcee6d602a9fc4e466bc7a3b3cd1b51addbe0f9f
7
- data.tar.gz: d657595e2a1fc91841bb159a2d1b94616b3d9b409ebec1b20d97065cae155f290e64976167de16003b0bd2c153111aa449bae8e70c6d7d0063a8c5533a7bf732
6
+ metadata.gz: 5fd278f6bdac2ace57c27d07f55e58459324f93d8ad97fee3cd0fddc66bf0e91ad82ec141f89aa98da811cced66965c24eae651ead04f323add299cb2489117a
7
+ data.tar.gz: 700a1a34fe6307560c0df054b302c2a047036828b05c2454c4704e7b28a1acca4bdd04418bfb460166229d9c4714eed95ca857976a05059c9d82e5edf392a434
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- queryable_logs (0.1.4)
4
+ queryable_logs (0.1.5)
5
5
  activerecord (>= 4)
6
6
  activesupport (>= 4)
7
7
 
@@ -6,4 +6,5 @@ end
6
6
 
7
7
  Trail.logger = Logger.new(Trail::LogFile, 'daily', 7)
8
8
  Trail.logger.level = 'info' # could be debug, info, warn, error or fatal
9
- Trail.current_user_method = :current_user
9
+ Trail.current_user_method = :current_user
10
+ Trail.skip_controller_actions = [] # Should be a small list of controller#action items
@@ -13,6 +13,9 @@ class CreateTrailLogs < ActiveRecord::Migration<%= migration_version %>
13
13
  t.string :request_url
14
14
  t.string :sig
15
15
 
16
+ t.index :sig, unique: true
17
+ t.index :controller
18
+ t.index :action
16
19
  t.timestamps null: false
17
20
  end
18
21
  end
@@ -1,3 +1,3 @@
1
1
  module QueryableLogs
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -8,19 +8,21 @@ module QueryableLogs
8
8
 
9
9
  def write_to_trail_log
10
10
  # vid, mid, ip, vrb, url, ctl, act, fmt, res, p (must be last)
11
- log_string = "uid:%{user_id} ip:%{ip_address} vrb:%{http_verb} url:%{url} ctl:%{controller} act:%{action} fmt:%{format} res:%{response_code} p:%{params_as_json}" % {
12
- user_id: self.respond_to?(Trail.current_user_method) ? send(Trail.current_user_method).try(:id) : '',
13
- ip_address: request.remote_ip,
14
- http_verb: request.request_method,
15
- url: Nokogiri::HTML(request.fullpath).text.strip,
16
- controller: controller_path,
17
- action: action_name,
18
- format: request.format.symbol,
19
- params_as_json: Nokogiri::HTML(params.to_json).text.strip,
20
- response_code: response.code
21
- }
22
-
23
- Trail.logger.info(log_string)
11
+ if !Trail.skip_controller_actions.any? { |ca| ctr, act = ca.split('#'); ctr == controller_path && act == action_name }
12
+ log_string = "uid:%{user_id} ip:%{ip_address} vrb:%{http_verb} url:%{url} ctl:%{controller} act:%{action} fmt:%{format} res:%{response_code} p:%{params_as_json}" % {
13
+ user_id: self.respond_to?(Trail.current_user_method) ? send(Trail.current_user_method).try(:id) : '',
14
+ ip_address: request.remote_ip,
15
+ http_verb: request.request_method,
16
+ url: Nokogiri::HTML(request.fullpath).text.strip,
17
+ controller: controller_path,
18
+ action: action_name,
19
+ format: request.format.symbol,
20
+ params_as_json: Nokogiri::HTML(params.to_json).text.strip,
21
+ response_code: response.code
22
+ }
23
+
24
+ Trail.logger.info(log_string)
25
+ end
24
26
  end
25
27
  end
26
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: queryable_logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akshay Takkar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-12 00:00:00.000000000 Z
11
+ date: 2025-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord