rf_logger 0.3.1 → 0.3.2

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
  SHA1:
3
- metadata.gz: 76a7e84c1a3d1bd7e71eaf197030c475c25b0652
4
- data.tar.gz: 5a8c78e3ae4826e0d497bced3d13f57e2a188b11
3
+ metadata.gz: b595e7d05f3277b9c9835fa966c9c3a4a1e6fec9
4
+ data.tar.gz: aecb196b1dbd862dffab3ec5dc341ab68ec1e31b
5
5
  SHA512:
6
- metadata.gz: b7c5dd2ad6cbc9b713e143b081d0724ec56f770bee49f663605d354bc9dff3f9b232881d7cf449308d49c46efc1938dd8f80d69aa7fb2dd65f4e8b3b3a56cc4d
7
- data.tar.gz: 1915d7b1ca6d099d387a15b583b9bbb64790871dfddbaba509234d9b02edcc85c80df179cb2490d21b74dc74430844165d94ac64dd76dc9d586d4ac2d84a6afa
6
+ metadata.gz: 6b16adcfce60a563371920d59b2bfc05b701c5c74a0572bdaace67bf747914b95ae6128142f8f51eb4e3530c6d3768af99223d65877c7e563ad0fed2e7bd6d22
7
+ data.tar.gz: 96c307c32bb8880a67b3a159713d6734f990bd63a3ac2e1ea6c76235177ecac1a2b8add190331cb8e90eb0d70710c5bf615de914edab98bd05f0f130e662bc39
data/README.md CHANGED
@@ -16,16 +16,16 @@ The API provides helper methods for each severity (i.e. `Logger.debug`). In add
16
16
 
17
17
  This gem includes RfLogger::SimpleLogger, RfLogger::Sequel::Logger and RfLogger::ActiveRecord::Logger loggers as options that adhere to this API. The fields above should be passed into helper methods as a hash.
18
18
 
19
- ##Integration##
19
+ ## Integration
20
20
  Integrating RfLogger into your project requires the following steps:
21
21
  * Include the rf_logger code in your project
22
22
  * Create a migration
23
23
  * Add a model
24
24
 
25
- #### Including rf_logger ####
26
- Currently, RfLogger is included from the Github repo. Place the following in your Gemfile:
25
+ #### Including rf_logger
26
+ Place the following in your Gemfile:
27
27
 
28
- ```gem 'rf_logger', :github => 'renewablefunding/rf_logger' , :tag => "0.3.0"```
28
+ ```gem 'rf_logger', "0.3"```
29
29
 
30
30
  Also make sure you include rf_logger and the logger you're going to be using:
31
31
 
@@ -42,7 +42,16 @@ Alters Rails.logger to append `request_id=89f25715-3e5d-4d85-9352-843a1aeec7d0`
42
42
 
43
43
  #### Rory Requirements
44
44
 
45
- Support Rory => `0.7`
45
+ Support Rory => `0.8`
46
+
47
+
48
+ #### Debug Framework detection and loading plug-ins
49
+
50
+ Will puts to STDOUT frameworks detected and any errors.
51
+
52
+ ```ruby
53
+ ENV["RF_LOGGER_LOAD_DEBUG"] = "true"
54
+ ```
46
55
 
47
56
  #### RfLogger::RequestHeaders
48
57
 
@@ -69,7 +78,7 @@ RfLogger::RequestHeaders.new(accepts: "application/json").to_hash
69
78
 
70
79
  #### Migration
71
80
  Assuming your logger will persist to a database, you'll need to create a table. While the api should make it pretty easy to determine which fields you'll need, here are the guts of what you'd need for both the SequelLogger and RailsLogger:
72
- ######Sequel
81
+ ###### Sequel
73
82
  ```
74
83
  create_table :logs do
75
84
  primary_key :id
@@ -99,20 +108,20 @@ end
99
108
  #### Model
100
109
  Again, assuming you'll be using the SequelLogger or RailsLogger (or some other logger that persists to a datasource), you'll want to create a Model that wraps your logger. This is as simple as creating a class that inherits from your logger (though you can make it more complex as your project needs dictate):
101
110
 
102
- ######Sequel
111
+ ###### Sequel
103
112
  ```
104
113
  class Log < RfLogger::Sequel::Logger
105
114
  end
106
115
  ```
107
116
 
108
- ######ActiveRecord
117
+ ###### ActiveRecord
109
118
  ```
110
119
  class Log < RfLogger::ActiveRecord::Logger
111
120
  end
112
121
  ```
113
122
 
114
123
 
115
- ##Configuration##
124
+ ## Configuration
116
125
  Configuration mostly sets up additional notifications beyond the actual logging.
117
126
 
118
127
  ```ruby
@@ -131,7 +140,7 @@ end
131
140
 
132
141
  As you see above, you can specify different notifications for different levels or environments when you log an event.
133
142
 
134
- ##Notification##
143
+ ## Notification
135
144
  While you have to implement notifiers yourself, the API is fairly simple. The class must respond to .send_notification. The argument passed in is an object that includes a #subject (which can be defined in the configuration (see above), and #details, which is the metadata in YAML format. Future versions of this may allow for other transformations of the log data.
136
145
 
137
146
  Example:
@@ -4,10 +4,10 @@ module RfLogger
4
4
  def self.try_to_load(file)
5
5
  begin
6
6
  require file
7
- yield
8
7
  puts "RfLogger: Detected #{file}." if ENV["RF_LOGGER_LOAD_DEBUG"]
9
- rescue LoadError
10
- puts "RfLogger: #{file} not detected." if ENV["RF_LOGGER_LOAD_DEBUG"]
8
+ yield
9
+ rescue LoadError => e
10
+ puts "RfLogger: #{file} not detected.\n\t#{e.to_s}" if ENV["RF_LOGGER_LOAD_DEBUG"]
11
11
  end
12
12
  end
13
13
  end
@@ -15,4 +15,4 @@ end
15
15
  RfLogger.try_to_load("rails") { require "rf_logger/rails" }
16
16
  RfLogger.try_to_load("active_record") { require "rf_logger/active_record" }
17
17
  RfLogger.try_to_load("rory") { require "rf_logger/rory" }
18
- RfLogger.try_to_load("sequel") { require "rf_logger/sequel" }
18
+ RfLogger.try_to_load("sequel") { puts "RfLogger: require 'rf_logger/sequel'; before inheriting from RfLogger::Sequel::Logger" if ENV["RF_LOGGER_LOAD_DEBUG"] }
@@ -1 +1,2 @@
1
+ puts "RfLogger: ActiveRecord version #{ActiveRecord::VERSION::STRING}" if ENV["RF_LOGGER_LOAD_DEBUG"]
1
2
  require "rf_logger/active_record/logger"
@@ -1,5 +1,8 @@
1
1
  require "rf_logger/rails/rails_compatibility"
2
2
  require "rails/version"
3
- RfLogger::RailsCompatibility.new.call { require "rf_logger/rails/key_value_tagged_logging" }
3
+ puts "RfLogger: Rails version #{Rails::VERSION::STRING}" if ENV["RF_LOGGER_LOAD_DEBUG"]
4
+ RfLogger::RailsCompatibility.new.call {
5
+ require "rf_logger/rails/key_value_tagged_logging"
6
+ }
4
7
  require "rf_logger/request/request_headers"
5
8
  require "rf_logger/rails/initialize_request_middleware"
@@ -1,7 +1,7 @@
1
1
  module RfLogger
2
2
  class RailsCompatibility
3
- MAX = "5.0.99"
4
- MIN = "3.2"
3
+ MAX = "5.0.99"
4
+ MIN = "3.2"
5
5
  Incompatible = Class.new(StandardError)
6
6
 
7
7
  def initialize(rails_version: Gem::Version.new(::Rails::VERSION::STRING))
@@ -21,7 +21,8 @@ module RfLogger
21
21
  attr_reader :rails_version
22
22
 
23
23
  def rails_not_support_message
24
- raise Incompatible, "These patches change Rails private methods and are only known to work for Rails #{MIN} through #{MAX}"
24
+ return unless ENV["RF_LOGGER_LOAD_DEBUG"] = "true"
25
+ puts "RfLogger: These patches change Rails private methods and are only known to work for Rails #{MIN} through #{MAX}. Current version #{rails_version}"
25
26
  end
26
27
 
27
28
  def rails_supported?
@@ -1,2 +1,9 @@
1
- require "rf_logger/rory/initialize_request_middleware"
2
- require "rf_logger/request/request_headers"
1
+ require "rory/version"
2
+
3
+ if Gem::Version.new(Rory::VERSION) >= Gem::Version.new("0.8")
4
+ puts "RfLogger: Rory version #{Rory::VERSION}" if ENV["RF_LOGGER_LOAD_DEBUG"]
5
+ require "rf_logger/rory/initialize_request_middleware"
6
+ require "rf_logger/request/request_headers"
7
+ else
8
+ puts "RfLogger: requires Rory 0.8 or greater. Version #{Rory::VERSION} is not support." if ENV["RF_LOGGER_LOAD_DEBUG"]
9
+ end
@@ -1,9 +1,5 @@
1
1
  require "rf_logger/request/request_middleware"
2
- require "rory/version"
3
2
 
4
- unless Gem::Version.new(Rory::VERSION) >= Gem::Version.new("0.8")
5
- raise "RfLogger require Rory 0.8 or greater. Version #{Rory::VERSION} is not support."
6
- end
7
3
  Rory::Application.initializers.insert_after "rory.request_middleware", "rf_logger.request_middleware" do |app|
8
4
  app.middleware.insert_after Rory::RequestId, RfLogger::RequestMiddleware
9
5
  end
@@ -1,2 +1,3 @@
1
+ puts "RfLogger: Sequel version #{Sequel::VERSION}" if ENV["RF_LOGGER_LOAD_DEBUG"]
1
2
  require "rf_logger/sequel/base"
2
- require "rf_logger/sequel/model"
3
+ require "rf_logger/sequel/logger"
@@ -1,3 +1,3 @@
1
1
  module RfLogger
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -1,3 +1,5 @@
1
+ require "rf_logger/log_for_notification"
2
+
1
3
  describe RfLogger::LogForNotification do
2
4
  subject { described_class.new(
3
5
  :actor => 'fruit_cocktail',
@@ -7,12 +7,12 @@ RSpec.describe RfLogger::RailsCompatibility do
7
7
 
8
8
  context "far left" do
9
9
  let(:rails_version) { 2.9 }
10
- it { expect { subject.call }.to raise_error(described_class::Incompatible) }
10
+ it { expect { |b| subject.call(&b) }.to_not yield_control }
11
11
  end
12
12
 
13
13
  context "edge left" do
14
14
  let(:rails_version) { 3.1 }
15
- it { expect { subject.call }.to raise_error(described_class::Incompatible) }
15
+ it { expect { |b| subject.call(&b) }.to_not yield_control }
16
16
  end
17
17
 
18
18
  context "middle edge left" do
@@ -32,11 +32,11 @@ RSpec.describe RfLogger::RailsCompatibility do
32
32
 
33
33
  context "edge right" do
34
34
  let(:rails_version) { 5.1 }
35
- it { expect { subject.call }.to raise_error(described_class::Incompatible) }
35
+ it { expect { |b| subject.call(&b) }.to_not yield_control }
36
36
  end
37
37
 
38
38
  context "far right" do
39
39
  let(:rails_version) {6.0}
40
- it { expect { subject.call }.to raise_error(described_class::Incompatible) }
40
+ it { expect { |b| subject.call(&b) }.to_not yield_control }
41
41
  end
42
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rf_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Zeisler