queryable_logs 0.1.0 → 0.1.1

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: 23b8ae959b8c34959d0db89adfcba5e50b38011264947b4de53f626bd4d1bb64
4
- data.tar.gz: 1f9aeb0b1b2b5b8c40f0bb4245859ed06d72066f45abf6aac885f295cf0e6964
3
+ metadata.gz: 24a41e93a9b5a82d65308c7a0328fe06e09e258da2bbdecf22318787f8b7bd12
4
+ data.tar.gz: fa7a6fcb05f84ef1e93c46f615fd24e61a378b6a94b45654b3d5a67cffe8a9c1
5
5
  SHA512:
6
- metadata.gz: 13c600df1ba652861169e0b9495dd1d98a71723d8e663a8b219a4c8ad872f04d906453e593cfc70e3b8ef7d8d927bdca53666c08fa268b0cd0637cf3736dcc41
7
- data.tar.gz: 6cd4fb3c21e7e4e513e6df4a7aad840f34cb9512d5d79cc4d7004f83aa8896d89d66ad7ebb27dba3084e66421916c86c0e2ebbc856fd2062b84b2f3018db142a
6
+ metadata.gz: 7be44957dc9085326c0316c9f3494376886e6a486e930ea2d74e79456e10f33d4eb788ee45876bb46c3bb94f1dee20c69e9940d374a8c7b8a1587dfed8892def
7
+ data.tar.gz: 80ca1801204f4c5bda12e7a36a38563959b14aae1eb3cccf866da873ff9b0ee764153c0e91025ae150380cd1d7011a541b944eb7bde506b91573d3df7b9ee649
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- queryable_logs (0.1.0)
4
+ queryable_logs (0.1.1)
5
5
  rails (>= 4)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -21,12 +21,54 @@ Or install it yourself as:
21
21
  Run
22
22
  `rails g queryable_logs`.
23
23
 
24
- This will generate a migration file and an initializer file. queryable_logs also logs the current user id. Let the gem know which method you are using to get the current user. Default is set to `current_user`.
24
+ This will generate a migration file.
25
+ ```ruby
26
+ class CreateTrailLogs < ActiveRecord::Migration
27
+ def change
28
+ create_table :trail_logs do |t|
29
+ t.integer :user_id
30
+ t.string :ip_address
31
+ t.string :controller
32
+ t.string :action
33
+ t.string :format
34
+ t.string :http_verb
35
+ t.text :params_hash
36
+ t.datetime :logged_at
37
+ t.string :response_code
38
+ t.string :request_url
39
+ t.string :sig
40
+
41
+ t.timestamps null: false
42
+ end
43
+ end
44
+ end
45
+ ```
46
+ and an initializer file.
47
+ ```ruby
48
+ class Trail
49
+ cattr_accessor :current_user_method, :logger, :saving_logs
50
+ LogFile = Rails.root.join('log', 'trail.log')
51
+ delegate :debug, :info, :warn, :error, :fatal, :to => :logger
52
+ end
53
+
54
+ Trail.logger = Logger.new(Trail::LogFile)
55
+ Trail.logger.level = 'info' # could be debug, info, warn, error or fatal
56
+ Trail.current_user_method = :current_user
57
+ ```
58
+ queryable_logs also logs the current user id. Let the gem know which method you are using to get the current user. Default is set to `current_user`.
59
+
60
+ Finally, include the `QueryableLogs::WriteLog` in the base controller, typically the `ApplicationController`.
61
+ ```ruby
62
+ class ApplicationController < ActionController::Base
63
+ include QueryableLogs::WriteLog
64
+ end
65
+ ```
66
+
67
+ Enter the following task to your crontab `rake parse:logs_to_db`
68
+
69
+ eg: `0 * * * * cd /Users/akshaytakkar/sample_rails_app && /Users/akshaytakkar/.rvm/wrappers/ruby-3.1.0/rake db:parse_log_and_save_trails >> /Users/akshaytakkar/sample_rails_app/log/worker.log 2>&1`
25
70
 
26
- Enter the following task to your crontab
27
- `rake parse:logs_to_db`
28
- eg:
29
- `* * * * * cd /Users/akshaytakkar/sample_rails_app && /Users/akshaytakkar/.rvm/wrappers/ruby-3.1.0/rake db:parse_log_and_save_trails >> /Users/akshaytakkar/sample_rails_app/log/worker.log 2>&1`
71
+ This will run the `rake parse:logs_to_db` rake task every hour and log any errors or output from the task to `worker.log` file.
30
72
 
31
73
  ## Usage
32
74
 
@@ -6,5 +6,4 @@ end
6
6
 
7
7
  Trail.logger = Logger.new(Trail::LogFile)
8
8
  Trail.logger.level = 'info' # could be debug, info, warn, error or fatal
9
- Trail.current_user_method = :current_user
10
- Trail.saving_logs = false
9
+ Trail.current_user_method = :current_user
@@ -1,3 +1,3 @@
1
1
  module QueryableLogs
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akshay Takkar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-10 00:00:00.000000000 Z
11
+ date: 2023-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails