timberio 1.0.0.beta1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -2
  3. data/.rspec +2 -0
  4. data/.yardopts +6 -0
  5. data/Appraisals +4 -0
  6. data/Gemfile +9 -1
  7. data/LICENSE.md +15 -0
  8. data/README.md +170 -8
  9. data/circle.yml +11 -8
  10. data/lib/timber/config.rb +11 -18
  11. data/lib/timber/context.rb +9 -68
  12. data/lib/timber/contexts/custom.rb +27 -0
  13. data/lib/timber/contexts/http.rb +28 -0
  14. data/lib/timber/contexts/organization.rb +24 -22
  15. data/lib/timber/contexts/user.rb +25 -28
  16. data/lib/timber/contexts.rb +7 -20
  17. data/lib/timber/current_context.rb +26 -41
  18. data/lib/timber/event.rb +13 -0
  19. data/lib/timber/events/controller_call.rb +40 -0
  20. data/lib/timber/events/custom.rb +42 -0
  21. data/lib/timber/events/exception.rb +35 -0
  22. data/lib/timber/events/http_request.rb +50 -0
  23. data/lib/timber/events/http_response.rb +36 -0
  24. data/lib/timber/events/sql_query.rb +26 -0
  25. data/lib/timber/events/template_render.rb +26 -0
  26. data/lib/timber/events.rb +37 -0
  27. data/lib/timber/frameworks/rails.rb +3 -14
  28. data/lib/timber/frameworks.rb +8 -10
  29. data/lib/timber/log_devices/http.rb +72 -13
  30. data/lib/timber/log_devices.rb +8 -4
  31. data/lib/timber/log_entry.rb +59 -0
  32. data/lib/timber/logger.rb +136 -13
  33. data/lib/timber/probe.rb +6 -4
  34. data/lib/timber/probes/action_controller_log_subscriber/log_subscriber.rb +64 -0
  35. data/lib/timber/probes/action_controller_log_subscriber.rb +20 -0
  36. data/lib/timber/probes/action_dispatch_debug_exceptions.rb +59 -35
  37. data/lib/timber/probes/action_view_log_subscriber/log_subscriber.rb +62 -0
  38. data/lib/timber/probes/action_view_log_subscriber.rb +20 -0
  39. data/lib/timber/probes/active_record_log_subscriber/log_subscriber.rb +72 -0
  40. data/lib/timber/probes/active_record_log_subscriber.rb +20 -0
  41. data/lib/timber/probes/rack_http_context.rb +51 -0
  42. data/lib/timber/probes/rails_rack_logger.rb +76 -0
  43. data/lib/timber/probes.rb +13 -16
  44. data/lib/timber/util/active_support_log_subscriber.rb +33 -0
  45. data/lib/timber/util/hash.rb +14 -0
  46. data/lib/timber/util.rb +8 -0
  47. data/lib/timber/version.rb +2 -2
  48. data/lib/timber.rb +6 -11
  49. data/spec/spec_helper.rb +7 -4
  50. data/spec/support/rails.rb +9 -5
  51. data/spec/support/timber.rb +1 -20
  52. data/spec/timber/events_spec.rb +55 -0
  53. data/spec/timber/log_devices/http_spec.rb +62 -0
  54. data/spec/timber/logger_spec.rb +68 -0
  55. data/spec/timber/probes/action_controller_log_subscriber_spec.rb +70 -0
  56. data/spec/timber/probes/action_dispatch_debug_exceptions_spec.rb +24 -18
  57. data/spec/timber/probes/action_view_log_subscriber_spec.rb +61 -0
  58. data/spec/timber/probes/active_record_log_subscriber_spec.rb +49 -0
  59. data/spec/timber/probes/rack_http_context_spec.rb +54 -0
  60. data/spec/timber/probes/rails_rack_logger_spec.rb +46 -0
  61. data/timberio.gemspec +2 -0
  62. metadata +62 -123
  63. data/.codeclimate.yml +0 -34
  64. data/LICENSE +0 -38
  65. data/Rakefile +0 -4
  66. data/TODO +0 -4
  67. data/benchmark/README.md +0 -26
  68. data/benchmark/rails_request.rb +0 -68
  69. data/benchmark/support/rails.rb +0 -69
  70. data/docs/installation/rails_on_heroku.md +0 -31
  71. data/docs/installation/rails_over_http.md +0 -22
  72. data/gemfiles/rails_3.0.X.gemfile +0 -25
  73. data/gemfiles/rails_3.1.X.gemfile +0 -25
  74. data/gemfiles/rails_3.2.X.gemfile +0 -25
  75. data/gemfiles/rails_4.0.X.gemfile +0 -26
  76. data/gemfiles/rails_4.1.X.gemfile +0 -26
  77. data/gemfiles/rails_4.2.X.gemfile +0 -26
  78. data/gemfiles/rails_5.0.X.gemfile +0 -26
  79. data/gemfiles/rails_edge.gemfile +0 -27
  80. data/lib/timber/api_settings.rb +0 -17
  81. data/lib/timber/bootstrap.rb +0 -45
  82. data/lib/timber/context_snapshot.rb +0 -64
  83. data/lib/timber/contexts/dynamic_values.rb +0 -59
  84. data/lib/timber/contexts/exception.rb +0 -40
  85. data/lib/timber/contexts/http_request.rb +0 -22
  86. data/lib/timber/contexts/http_requests/action_controller_specific.rb +0 -48
  87. data/lib/timber/contexts/http_requests/rack/params.rb +0 -26
  88. data/lib/timber/contexts/http_requests/rack.rb +0 -105
  89. data/lib/timber/contexts/http_response.rb +0 -19
  90. data/lib/timber/contexts/http_responses/action_controller.rb +0 -76
  91. data/lib/timber/contexts/logger.rb +0 -33
  92. data/lib/timber/contexts/organizations/action_controller.rb +0 -34
  93. data/lib/timber/contexts/server.rb +0 -21
  94. data/lib/timber/contexts/servers/heroku_specific.rb +0 -48
  95. data/lib/timber/contexts/sql_queries/active_record.rb +0 -30
  96. data/lib/timber/contexts/sql_queries/active_record_specific/binds.rb +0 -37
  97. data/lib/timber/contexts/sql_queries/active_record_specific.rb +0 -59
  98. data/lib/timber/contexts/sql_query.rb +0 -18
  99. data/lib/timber/contexts/template_render.rb +0 -17
  100. data/lib/timber/contexts/template_renders/action_view.rb +0 -29
  101. data/lib/timber/contexts/template_renders/action_view_specific.rb +0 -51
  102. data/lib/timber/contexts/users/action_controller.rb +0 -34
  103. data/lib/timber/current_line_indexes.rb +0 -35
  104. data/lib/timber/internal_logger.rb +0 -35
  105. data/lib/timber/log_device.rb +0 -40
  106. data/lib/timber/log_devices/heroku_logplex/hybrid_formatter.rb +0 -14
  107. data/lib/timber/log_devices/heroku_logplex.rb +0 -14
  108. data/lib/timber/log_devices/http/log_pile.rb +0 -86
  109. data/lib/timber/log_devices/http/log_truck/delivery.rb +0 -116
  110. data/lib/timber/log_devices/http/log_truck.rb +0 -87
  111. data/lib/timber/log_devices/io/formatter.rb +0 -46
  112. data/lib/timber/log_devices/io/hybrid_formatter.rb +0 -41
  113. data/lib/timber/log_devices/io/hybrid_hidden_formatter.rb +0 -36
  114. data/lib/timber/log_devices/io/json_formatter.rb +0 -11
  115. data/lib/timber/log_devices/io/logfmt_formatter.rb +0 -11
  116. data/lib/timber/log_devices/io.rb +0 -41
  117. data/lib/timber/log_line.rb +0 -33
  118. data/lib/timber/macros/compactor.rb +0 -16
  119. data/lib/timber/macros/date_formatter.rb +0 -9
  120. data/lib/timber/macros/deep_merger.rb +0 -11
  121. data/lib/timber/macros/logfmt_encoder.rb +0 -77
  122. data/lib/timber/macros.rb +0 -4
  123. data/lib/timber/patterns/delegated_singleton.rb +0 -21
  124. data/lib/timber/patterns/to_json.rb +0 -22
  125. data/lib/timber/patterns/to_logfmt.rb +0 -9
  126. data/lib/timber/patterns.rb +0 -3
  127. data/lib/timber/probes/action_controller_base.rb +0 -31
  128. data/lib/timber/probes/active_support_log_subscriber/action_controller.rb +0 -15
  129. data/lib/timber/probes/active_support_log_subscriber/action_view.rb +0 -26
  130. data/lib/timber/probes/active_support_log_subscriber/active_record.rb +0 -13
  131. data/lib/timber/probes/active_support_log_subscriber.rb +0 -62
  132. data/lib/timber/probes/heroku.rb +0 -30
  133. data/lib/timber/probes/logger.rb +0 -31
  134. data/lib/timber/probes/rack.rb +0 -36
  135. data/lib/timber/probes/server.rb +0 -18
  136. data/spec/timber/bootstrap_spec.rb +0 -31
  137. data/spec/timber/context_snapshot_spec.rb +0 -10
  138. data/spec/timber/context_spec.rb +0 -4
  139. data/spec/timber/contexts/exception_spec.rb +0 -34
  140. data/spec/timber/contexts/organizations/action_controller_spec.rb +0 -49
  141. data/spec/timber/contexts/users/action_controller_spec.rb +0 -65
  142. data/spec/timber/current_line_indexes_spec.rb +0 -40
  143. data/spec/timber/frameworks/rails_spec.rb +0 -9
  144. data/spec/timber/log_devices/heroku_logplex_spec.rb +0 -45
  145. data/spec/timber/log_devices/http/log_truck/delivery_spec.rb +0 -66
  146. data/spec/timber/log_devices/http/log_truck_spec.rb +0 -65
  147. data/spec/timber/log_devices/io/hybrid_hidden_formatter_spec.rb +0 -28
  148. data/spec/timber/log_line_spec.rb +0 -49
  149. data/spec/timber/macros/compactor_spec.rb +0 -19
  150. data/spec/timber/macros/logfmt_encoder_spec.rb +0 -89
  151. data/spec/timber/patterns/to_json_spec.rb +0 -40
  152. data/spec/timber/probes/action_controller_base_spec.rb +0 -43
  153. data/spec/timber/probes/action_controller_log_subscriber/action_controller_spec.rb +0 -35
  154. data/spec/timber/probes/action_controller_log_subscriber/action_view_spec.rb +0 -44
  155. data/spec/timber/probes/action_controller_log_subscriber/active_record_spec.rb +0 -26
  156. data/spec/timber/probes/logger_spec.rb +0 -20
  157. data/spec/timber/probes/rack_spec.rb +0 -26
@@ -0,0 +1,61 @@
1
+ require "spec_helper"
2
+
3
+ describe Timber::Probes::ActionViewLogSubscriber do
4
+ if defined?(described_class::LogSubscriber)
5
+ describe described_class::LogSubscriber do
6
+ let(:time) { Time.utc(2016, 9, 1, 12, 0, 0) }
7
+ let(:io) { StringIO.new }
8
+ let(:logger) do
9
+ logger = Timber::Logger.new(io)
10
+ logger.level = ::Logger::WARN
11
+ logger
12
+ end
13
+
14
+ around(:each) do |example|
15
+ class ActionViewLogSubscriberController < ActionController::Base
16
+ layout nil
17
+
18
+ def index
19
+ render template: "template"
20
+ end
21
+
22
+ def method_for_action(action_name)
23
+ action_name
24
+ end
25
+ end
26
+
27
+ ::RailsApp.routes.draw do
28
+ get 'action_view_log_subscriber' => 'action_view_log_subscriber#index'
29
+ end
30
+
31
+ Timecop.freeze(time) { example.run }
32
+
33
+ Object.send(:remove_const, :ActionViewLogSubscriberController)
34
+ end
35
+
36
+ describe "#sql" do
37
+ it "should not log if the level is not sufficient" do
38
+ allow_any_instance_of(Timber::Probes::ActionViewLogSubscriber::LogSubscriber).to receive(:logger).and_return(logger)
39
+ dispatch_rails_request("/action_view_log_subscriber")
40
+ expect(io.string).to eq("")
41
+ end
42
+
43
+ context "with an info level" do
44
+ around(:each) do |example|
45
+ old_level = logger.level
46
+ logger.level = ::Logger::INFO
47
+ example.run
48
+ logger.level = old_level
49
+ end
50
+
51
+ it "should log the controller call event" do
52
+ allow_any_instance_of(Timber::Probes::ActionViewLogSubscriber::LogSubscriber).to receive(:logger).and_return(logger)
53
+ dispatch_rails_request("/action_view_log_subscriber")
54
+ message = " Rendered spec/support/rails/templates/template.html (0.0ms) @timber.io {\"level\":\"info\",\"dt\":\"2016-09-01T12:00:00.000000Z\",\"event\":{\"template_render\":{\"name\":\"spec/support/rails/templates/template.html\",\"time_ms\":0.0}},\"context\":{\"http\":{\"method\":\"GET\",\"path\":\"/action_view_log_subscriber\",\"remote_addr\":\"123.456.789.10\",\"request_id\":\"unique-request-id-1234\"}}}\n"
55
+ expect(io.string).to eq(message)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,49 @@
1
+ require "spec_helper"
2
+
3
+ describe Timber::Probes::ActiveRecordLogSubscriber do
4
+ if defined?(described_class::LogSubscriber)
5
+ describe described_class::LogSubscriber do
6
+ let(:time) { Time.utc(2016, 9, 1, 12, 0, 0) }
7
+ let(:io) { StringIO.new }
8
+ let(:logger) do
9
+ logger = Timber::Logger.new(io)
10
+ logger.level = ::Logger::INFO
11
+ logger
12
+ end
13
+
14
+ around(:each) do |example|
15
+ old_logger = ::ActiveRecord::Base.logger
16
+ ::ActiveRecord::Base.logger = logger
17
+
18
+ Timecop.freeze(time) { example.run }
19
+
20
+ ::ActiveRecord::Base.logger = old_logger
21
+ end
22
+
23
+ describe "#sql" do
24
+ it "should not log if the level is not sufficient" do
25
+ User.order("users.id DESC").all.collect # collect kicks the sql because it is lazily executed
26
+ expect(io.string).to eq("")
27
+ end
28
+
29
+ context "with an info level" do
30
+ around(:each) do |example|
31
+ old_level = logger.level
32
+ logger.level = ::Logger::DEBUG
33
+ example.run
34
+ logger.level = old_level
35
+ end
36
+
37
+ it "should log the controller call event" do
38
+ User.order("users.id DESC").all.collect # collect kicks the sql because it is lazily executed
39
+ message = " \e[1m\e[36mUser Load (0.0ms)\e[0m \e[1m\e[34mSELECT \"users\".* FROM \"users\" ORDER BY users.id DESC\e[0m @timber.io {\"level\":\"debug\",\"dt\":\"2016-09-01T12:00:00.000000Z\",\"event\":{\"sql_query\":{\"sql\":\"SELECT \\\"users\\\".* FROM \\\"users\\\" ORDER BY users.id DESC\",\"time_ms\":0.0}}}\n"
40
+ # Rails 4.X adds random spaces :/
41
+ string = io.string.gsub(" ORDER BY", " ORDER BY")
42
+ string = string.gsub(" ORDER BY", " ORDER BY")
43
+ expect(string).to eq(message)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,54 @@
1
+ require "spec_helper"
2
+
3
+ describe Timber::Probes::RackHTTPContext do
4
+ describe described_class::Middleware do
5
+ let(:time) { Time.utc(2016, 9, 1, 12, 0, 0) }
6
+ let(:io) { StringIO.new }
7
+ let(:logger) do
8
+ logger = Timber::Logger.new(io)
9
+ logger.level = ::Logger::INFO
10
+ logger
11
+ end
12
+
13
+ around(:each) do |example|
14
+ class RackHttpController < ActionController::Base
15
+ layout nil
16
+
17
+ def index
18
+ Thread.current[:_timber_context] = Timber::CurrentContext.instance.snapshot
19
+ render json: {}
20
+ end
21
+
22
+ def method_for_action(action_name)
23
+ action_name
24
+ end
25
+ end
26
+
27
+ ::RailsApp.routes.draw do
28
+ get '/rack_http' => 'rack_http#index'
29
+ end
30
+
31
+ Timecop.freeze(time) { example.run }
32
+
33
+ Object.send(:remove_const, :RackHttpController)
34
+ end
35
+
36
+ describe "#process" do
37
+ it "should set the context" do
38
+ allow(Benchmark).to receive(:ms).and_return(1).and_yield
39
+ allow_any_instance_of(Timber::Probes::ActionControllerLogSubscriber::LogSubscriber).to receive(:logger).and_return(logger)
40
+
41
+ dispatch_rails_request("/rack_http")
42
+ http_context = Thread.current[:_timber_context][:http]
43
+
44
+ expect(http_context).to be_kind_of(Timber::Contexts::HTTP)
45
+ expect(http_context.method).to eq("GET")
46
+ expect(http_context.path).to eq("/rack_http")
47
+ expect(http_context.remote_addr).to eq("123.456.789.10")
48
+ expect(http_context.request_id).to_not be_nil
49
+ message = "Processing by RackHttpController#index as HTML @timber.io {\"level\":\"info\",\"dt\":\"2016-09-01T12:00:00.000000Z\",\"event\":{\"controller_call\":{\"controller\":\"RackHttpController\",\"action\":\"index\"}},\"context\":{\"http\":{\"method\":\"GET\",\"path\":\"/rack_http\",\"remote_addr\":\"123.456.789.10\",\"request_id\":\"unique-request-id-1234\"}}}\nCompleted 200 OK in 0.0ms (Views: 1.0ms) @timber.io {\"level\":\"info\",\"dt\":\"2016-09-01T12:00:00.000000Z\",\"event\":{\"http_response\":{\"status\":200,\"time_ms\":0.0}},\"context\":{\"http\":{\"method\":\"GET\",\"path\":\"/rack_http\",\"remote_addr\":\"123.456.789.10\",\"request_id\":\"unique-request-id-1234\"}}}\n"
50
+ expect(io.string).to eq(message)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,46 @@
1
+ require "spec_helper"
2
+
3
+ describe Timber::Probes::RailsRackLogger do
4
+ describe described_class::InstanceMethods do
5
+ let(:time) { Time.utc(2016, 9, 1, 12, 0, 0) }
6
+ let(:io) { StringIO.new }
7
+ let(:logger) do
8
+ logger = Timber::Logger.new(io)
9
+ logger.level = ::Logger::INFO
10
+ logger
11
+ end
12
+
13
+ around(:each) do |example|
14
+ class RailsRackLoggerController < ActionController::Base
15
+ layout nil
16
+
17
+ def index
18
+ render json: {}
19
+ end
20
+
21
+ def method_for_action(action_name)
22
+ action_name
23
+ end
24
+ end
25
+
26
+ ::RailsApp.routes.draw do
27
+ get '/rails_rack_logger' => 'rails_rack_logger#index'
28
+ end
29
+
30
+ Timecop.freeze(time) { example.run }
31
+
32
+ Object.send(:remove_const, :RailsRackLoggerController)
33
+ end
34
+
35
+ describe "#started_request_message" do
36
+ it "should set the context" do
37
+ allow(::Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("production")) # Rails 3.2.X
38
+ allow(::Rails).to receive(:logger).and_return(logger) # Rails 3.2.X
39
+ allow_any_instance_of(::Rails::Rack::Logger).to receive(:logger).and_return(logger)
40
+ dispatch_rails_request("/rails_rack_logger")
41
+ message = "Started GET \"/rails_rack_logger\" for 123.456.789.10 @timber.io {\"level\":\"info\",\"dt\":\"2016-09-01T12:00:00.000000Z\",\"event\":{\"http_request\":{\"host\":\"example.org\",\"method\":\"GET\",\"path\":\"/rails_rack_logger\",\"port\":80,\"headers\":{\"remote_addr\":\"123.456.789.10\",\"request_id\":\"unique-request-id-1234\"}}},\"context\":{\"http\":{\"method\":\"GET\",\"path\":\"/rails_rack_logger\",\"remote_addr\":\"123.456.789.10\",\"request_id\":\"unique-request-id-1234\"}}}\n"
42
+ expect(io.string).to eq(message)
43
+ end
44
+ end
45
+ end
46
+ end
data/timberio.gemspec CHANGED
@@ -17,4 +17,6 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
+
21
+ s.add_dependency("msgpack", "~> 1.0")
20
22
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timberio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timber Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-14 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2016-12-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: msgpack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
13
27
  description:
14
28
  email:
15
29
  - hi@timber.io
@@ -17,99 +31,52 @@ executables: []
17
31
  extensions: []
18
32
  extra_rdoc_files: []
19
33
  files:
20
- - ".codeclimate.yml"
21
34
  - ".gitignore"
35
+ - ".rspec"
36
+ - ".yardopts"
22
37
  - Appraisals
23
38
  - Gemfile
24
- - LICENSE
39
+ - LICENSE.md
25
40
  - README.md
26
- - Rakefile
27
- - TODO
28
- - benchmark/README.md
29
- - benchmark/rails_request.rb
30
- - benchmark/support/rails.rb
31
41
  - circle.yml
32
- - docs/installation/rails_on_heroku.md
33
- - docs/installation/rails_over_http.md
34
- - gemfiles/rails_3.0.X.gemfile
35
- - gemfiles/rails_3.1.X.gemfile
36
- - gemfiles/rails_3.2.X.gemfile
37
- - gemfiles/rails_4.0.X.gemfile
38
- - gemfiles/rails_4.1.X.gemfile
39
- - gemfiles/rails_4.2.X.gemfile
40
- - gemfiles/rails_5.0.X.gemfile
41
- - gemfiles/rails_edge.gemfile
42
42
  - lib/timber.rb
43
- - lib/timber/api_settings.rb
44
- - lib/timber/bootstrap.rb
45
43
  - lib/timber/config.rb
46
44
  - lib/timber/context.rb
47
- - lib/timber/context_snapshot.rb
48
45
  - lib/timber/contexts.rb
49
- - lib/timber/contexts/dynamic_values.rb
50
- - lib/timber/contexts/exception.rb
51
- - lib/timber/contexts/http_request.rb
52
- - lib/timber/contexts/http_requests/action_controller_specific.rb
53
- - lib/timber/contexts/http_requests/rack.rb
54
- - lib/timber/contexts/http_requests/rack/params.rb
55
- - lib/timber/contexts/http_response.rb
56
- - lib/timber/contexts/http_responses/action_controller.rb
57
- - lib/timber/contexts/logger.rb
46
+ - lib/timber/contexts/custom.rb
47
+ - lib/timber/contexts/http.rb
58
48
  - lib/timber/contexts/organization.rb
59
- - lib/timber/contexts/organizations/action_controller.rb
60
- - lib/timber/contexts/server.rb
61
- - lib/timber/contexts/servers/heroku_specific.rb
62
- - lib/timber/contexts/sql_queries/active_record.rb
63
- - lib/timber/contexts/sql_queries/active_record_specific.rb
64
- - lib/timber/contexts/sql_queries/active_record_specific/binds.rb
65
- - lib/timber/contexts/sql_query.rb
66
- - lib/timber/contexts/template_render.rb
67
- - lib/timber/contexts/template_renders/action_view.rb
68
- - lib/timber/contexts/template_renders/action_view_specific.rb
69
49
  - lib/timber/contexts/user.rb
70
- - lib/timber/contexts/users/action_controller.rb
71
50
  - lib/timber/current_context.rb
72
- - lib/timber/current_line_indexes.rb
51
+ - lib/timber/event.rb
52
+ - lib/timber/events.rb
53
+ - lib/timber/events/controller_call.rb
54
+ - lib/timber/events/custom.rb
55
+ - lib/timber/events/exception.rb
56
+ - lib/timber/events/http_request.rb
57
+ - lib/timber/events/http_response.rb
58
+ - lib/timber/events/sql_query.rb
59
+ - lib/timber/events/template_render.rb
73
60
  - lib/timber/frameworks.rb
74
61
  - lib/timber/frameworks/rails.rb
75
- - lib/timber/internal_logger.rb
76
- - lib/timber/log_device.rb
77
62
  - lib/timber/log_devices.rb
78
- - lib/timber/log_devices/heroku_logplex.rb
79
- - lib/timber/log_devices/heroku_logplex/hybrid_formatter.rb
80
63
  - lib/timber/log_devices/http.rb
81
- - lib/timber/log_devices/http/log_pile.rb
82
- - lib/timber/log_devices/http/log_truck.rb
83
- - lib/timber/log_devices/http/log_truck/delivery.rb
84
- - lib/timber/log_devices/io.rb
85
- - lib/timber/log_devices/io/formatter.rb
86
- - lib/timber/log_devices/io/hybrid_formatter.rb
87
- - lib/timber/log_devices/io/hybrid_hidden_formatter.rb
88
- - lib/timber/log_devices/io/json_formatter.rb
89
- - lib/timber/log_devices/io/logfmt_formatter.rb
90
- - lib/timber/log_line.rb
64
+ - lib/timber/log_entry.rb
91
65
  - lib/timber/logger.rb
92
- - lib/timber/macros.rb
93
- - lib/timber/macros/compactor.rb
94
- - lib/timber/macros/date_formatter.rb
95
- - lib/timber/macros/deep_merger.rb
96
- - lib/timber/macros/logfmt_encoder.rb
97
- - lib/timber/patterns.rb
98
- - lib/timber/patterns/delegated_singleton.rb
99
- - lib/timber/patterns/to_json.rb
100
- - lib/timber/patterns/to_logfmt.rb
101
66
  - lib/timber/probe.rb
102
67
  - lib/timber/probes.rb
103
- - lib/timber/probes/action_controller_base.rb
68
+ - lib/timber/probes/action_controller_log_subscriber.rb
69
+ - lib/timber/probes/action_controller_log_subscriber/log_subscriber.rb
104
70
  - lib/timber/probes/action_dispatch_debug_exceptions.rb
105
- - lib/timber/probes/active_support_log_subscriber.rb
106
- - lib/timber/probes/active_support_log_subscriber/action_controller.rb
107
- - lib/timber/probes/active_support_log_subscriber/action_view.rb
108
- - lib/timber/probes/active_support_log_subscriber/active_record.rb
109
- - lib/timber/probes/heroku.rb
110
- - lib/timber/probes/logger.rb
111
- - lib/timber/probes/rack.rb
112
- - lib/timber/probes/server.rb
71
+ - lib/timber/probes/action_view_log_subscriber.rb
72
+ - lib/timber/probes/action_view_log_subscriber/log_subscriber.rb
73
+ - lib/timber/probes/active_record_log_subscriber.rb
74
+ - lib/timber/probes/active_record_log_subscriber/log_subscriber.rb
75
+ - lib/timber/probes/rack_http_context.rb
76
+ - lib/timber/probes/rails_rack_logger.rb
77
+ - lib/timber/util.rb
78
+ - lib/timber/util/active_support_log_subscriber.rb
79
+ - lib/timber/util/hash.rb
113
80
  - lib/timber/version.rb
114
81
  - spec/spec_helper.rb
115
82
  - spec/support/action_controller.rb
@@ -124,29 +91,15 @@ files:
124
91
  - spec/support/timber.rb
125
92
  - spec/support/timecop.rb
126
93
  - spec/support/webmock.rb
127
- - spec/timber/bootstrap_spec.rb
128
- - spec/timber/context_snapshot_spec.rb
129
- - spec/timber/context_spec.rb
130
- - spec/timber/contexts/exception_spec.rb
131
- - spec/timber/contexts/organizations/action_controller_spec.rb
132
- - spec/timber/contexts/users/action_controller_spec.rb
133
- - spec/timber/current_line_indexes_spec.rb
134
- - spec/timber/frameworks/rails_spec.rb
135
- - spec/timber/log_devices/heroku_logplex_spec.rb
136
- - spec/timber/log_devices/http/log_truck/delivery_spec.rb
137
- - spec/timber/log_devices/http/log_truck_spec.rb
138
- - spec/timber/log_devices/io/hybrid_hidden_formatter_spec.rb
139
- - spec/timber/log_line_spec.rb
140
- - spec/timber/macros/compactor_spec.rb
141
- - spec/timber/macros/logfmt_encoder_spec.rb
142
- - spec/timber/patterns/to_json_spec.rb
143
- - spec/timber/probes/action_controller_base_spec.rb
144
- - spec/timber/probes/action_controller_log_subscriber/action_controller_spec.rb
145
- - spec/timber/probes/action_controller_log_subscriber/action_view_spec.rb
146
- - spec/timber/probes/action_controller_log_subscriber/active_record_spec.rb
94
+ - spec/timber/events_spec.rb
95
+ - spec/timber/log_devices/http_spec.rb
96
+ - spec/timber/logger_spec.rb
97
+ - spec/timber/probes/action_controller_log_subscriber_spec.rb
147
98
  - spec/timber/probes/action_dispatch_debug_exceptions_spec.rb
148
- - spec/timber/probes/logger_spec.rb
149
- - spec/timber/probes/rack_spec.rb
99
+ - spec/timber/probes/action_view_log_subscriber_spec.rb
100
+ - spec/timber/probes/active_record_log_subscriber_spec.rb
101
+ - spec/timber/probes/rack_http_context_spec.rb
102
+ - spec/timber/probes/rails_rack_logger_spec.rb
150
103
  - timberio.gemspec
151
104
  homepage: http://timber.io
152
105
  licenses: []
@@ -162,12 +115,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
115
  version: 1.9.0
163
116
  required_rubygems_version: !ruby/object:Gem::Requirement
164
117
  requirements:
165
- - - ">"
118
+ - - ">="
166
119
  - !ruby/object:Gem::Version
167
- version: 1.3.1
120
+ version: '0'
168
121
  requirements: []
169
122
  rubyforge_project:
170
- rubygems_version: 2.5.1
123
+ rubygems_version: 2.6.8
171
124
  signing_key:
172
125
  specification_version: 4
173
126
  summary: Make logging useful again.
@@ -185,26 +138,12 @@ test_files:
185
138
  - spec/support/timber.rb
186
139
  - spec/support/timecop.rb
187
140
  - spec/support/webmock.rb
188
- - spec/timber/bootstrap_spec.rb
189
- - spec/timber/context_snapshot_spec.rb
190
- - spec/timber/context_spec.rb
191
- - spec/timber/contexts/exception_spec.rb
192
- - spec/timber/contexts/organizations/action_controller_spec.rb
193
- - spec/timber/contexts/users/action_controller_spec.rb
194
- - spec/timber/current_line_indexes_spec.rb
195
- - spec/timber/frameworks/rails_spec.rb
196
- - spec/timber/log_devices/heroku_logplex_spec.rb
197
- - spec/timber/log_devices/http/log_truck/delivery_spec.rb
198
- - spec/timber/log_devices/http/log_truck_spec.rb
199
- - spec/timber/log_devices/io/hybrid_hidden_formatter_spec.rb
200
- - spec/timber/log_line_spec.rb
201
- - spec/timber/macros/compactor_spec.rb
202
- - spec/timber/macros/logfmt_encoder_spec.rb
203
- - spec/timber/patterns/to_json_spec.rb
204
- - spec/timber/probes/action_controller_base_spec.rb
205
- - spec/timber/probes/action_controller_log_subscriber/action_controller_spec.rb
206
- - spec/timber/probes/action_controller_log_subscriber/action_view_spec.rb
207
- - spec/timber/probes/action_controller_log_subscriber/active_record_spec.rb
141
+ - spec/timber/events_spec.rb
142
+ - spec/timber/log_devices/http_spec.rb
143
+ - spec/timber/logger_spec.rb
144
+ - spec/timber/probes/action_controller_log_subscriber_spec.rb
208
145
  - spec/timber/probes/action_dispatch_debug_exceptions_spec.rb
209
- - spec/timber/probes/logger_spec.rb
210
- - spec/timber/probes/rack_spec.rb
146
+ - spec/timber/probes/action_view_log_subscriber_spec.rb
147
+ - spec/timber/probes/active_record_log_subscriber_spec.rb
148
+ - spec/timber/probes/rack_http_context_spec.rb
149
+ - spec/timber/probes/rails_rack_logger_spec.rb
data/.codeclimate.yml DELETED
@@ -1,34 +0,0 @@
1
- engines:
2
- duplication:
3
- enabled: true
4
- config:
5
- languages:
6
- - ruby
7
- - javascript
8
- - python
9
- - php
10
- exclude_fingerprints:
11
- - 491dd5b768852a27a80385aa82cf7e58
12
- - 538d87ce2b9bc468129f55f4f3978e58
13
- - 3a467030ef89f45f0d86a03cb629fb75
14
- - 39cf272b046d1677fb4ee2b97afb4998
15
- - 2ad1dc6314661ff8bcf4fdaba7b13b5e
16
- rubocop:
17
- enabled: true
18
- checks:
19
- Rubocop/Lint/RescueException:
20
- enabled: false
21
- ratings:
22
- paths:
23
- - "**.inc"
24
- - "**.js"
25
- - "**.jsx"
26
- - "**.module"
27
- - "**.php"
28
- - "**.py"
29
- - "**.rb"
30
- exclude_paths:
31
- - benchmark/
32
- - docs/
33
- - gemfiles/
34
- - spec/
data/LICENSE DELETED
@@ -1,38 +0,0 @@
1
- All other components of this product are
2
- Copyright (c) 2016 Timber Technologies, Inc. All rights reserved.
3
-
4
- Certain inventions disclosed in this file may be claimed within
5
- patents owned or patent applications filed by Timber, Inc. or third
6
- parties.
7
-
8
- Subject to the terms of this notice, Timber grants you a
9
- nonexclusive, nontransferable license, without the right to
10
- sublicense, to (a) install and execute one copy of these files on any
11
- number of workstations owned or controlled by you and (b) distribute
12
- verbatim copies of these files to third parties. As a condition to the
13
- foregoing grant, you must provide this notice along with each copy you
14
- distribute and you must not remove, alter, or obscure this notice. All
15
- other use, reproduction, modification, distribution, or other
16
- exploitation of these files is strictly prohibited, except as may be set
17
- forth in a separate written license agreement between you and Timber.
18
- The terms of any such license agreement will control over this
19
- notice. The license stated above will be automatically terminated and
20
- revoked if you exceed its scope or violate any of the terms of this
21
- notice.
22
-
23
- This License does not grant permission to use the trade names,
24
- trademarks, service marks, or product names of Timber, except as
25
- required for reasonable and customary use in describing the origin of
26
- this file and reproducing the content of this notice. You may not
27
- mark or brand this file with any trade name, trademarks, service
28
- marks, or product names other than the original brand (if any)
29
- provided by Timber.
30
-
31
- Unless otherwise expressly agreed by Timber in a separate written
32
- license agreement, these files are provided AS IS, WITHOUT WARRANTY OF
33
- ANY KIND, including without any implied warranties of MERCHANTABILITY,
34
- FITNESS FOR A PARTICULAR PURPOSE, TITLE, or NON-INFRINGEMENT. As a
35
- condition to your use of these files, you are solely responsible for
36
- such use. Timber will have no liability to you for direct,
37
- indirect, consequential, incidental, special, or punitive damages or
38
- for lost profits or data.
data/Rakefile DELETED
@@ -1,4 +0,0 @@
1
- require 'rspec/core/rake_task'
2
- RSpec::Core::RakeTask.new(:spec) do |t|
3
- t.rspec_opts = '--order random'
4
- end
data/TODO DELETED
@@ -1,4 +0,0 @@
1
- * Task for tailing logs in the console?
2
- * Task for opening web / desktop app?
3
- * Track memory usage, but do it efficiently. Random process stat drops?
4
- * Re-think how the library logs itself. Should that be captured as well?
data/benchmark/README.md DELETED
@@ -1,26 +0,0 @@
1
- ## Benchmarking & Performance
2
-
3
- Timber was designed with an obsessive focus on performance and resource usage. In the `/benchmark` folder you'll find benchmarking tests.
4
-
5
-
6
- ```console
7
- +---------------------------+------------+-----------------+--------------+
8
- | Timber benchmarking. 10 requests per test. Times are "real" CPU time. |
9
- +---------------------------+------------+-----------------+--------------+
10
- | | Total | Per request avg | Per log line |
11
- +---------------------------+------------+-----------------+--------------+
12
- | Control | 0.0077939 | 0.00077939 | 2.598e-05 |
13
- | Timber probes only | 0.00694394 | 0.00069439 | 2.315e-05 |
14
- | Timber probes and logging | 0.00897193 | 0.00089719 | 2.991e-05 |
15
- +---------------------------+------------+-----------------+--------------+
16
- ```
17
-
18
- 1. `Control` - This is vanilla rails app without Timber installed.
19
- 2. `Timber probels only` - The same rails app but with *only* the `Timber::Probes` installed, isolating probes performance.
20
- 3. `Timber probes and logging` - Testing the full Timber library, probes and adding context to each log line.
21
-
22
- The benchmark can be run yourself via:
23
-
24
- ```console
25
- $ appraisal ruby benchmark/rails_request.rb
26
- ```
@@ -1,68 +0,0 @@
1
- #----------------------------------------------------------
2
- # This file demonstrates Rails performance with and without
3
- # the Timber library installed. Timber was designed with an
4
- # obsessive focus on performance and resource usage. The
5
- # below benchmarking test reveals this. A few notes:
6
- # 1. Both loggers are set to log to the same device.
7
- # 2. The log level is set to debug to maximize logging output.
8
- # 3. Timber is run last so that we can insert the probes after.
9
- # This ensures Timber does not affect the environment at all.
10
- # ---------------------------------------------------------
11
-
12
- $:.unshift File.dirname(__FILE__)
13
- require "support/rails"
14
- require "benchmark"
15
- require "logger"
16
- require "terminal-table"
17
-
18
- def line_count(io)
19
- io.rewind
20
- io.read.split("\n").size
21
- end
22
- ITERATIONS = 10
23
- PRECISION = 8
24
- test = Proc.new { ITERATIONS.times { Support::Rails.dispatch_rails_request("/") } }
25
-
26
- # Set a default logger
27
- io = StringIO.new
28
- Support::Rails.set_logger(io)
29
-
30
- # Control
31
- control = Benchmark.measure("Control", &test)
32
- control_per_req = control.real / ITERATIONS
33
- log_line_count = line_count(io)
34
- control_per_line = control_per_req / log_line_count
35
-
36
- # Reset logger and insert probes
37
- io = StringIO.new
38
- Support::Rails.set_logger(io)
39
- Timber::Config.enabled = true
40
- Timber::Bootstrap.bootstrap!(RailsApp.config.app_middleware, ::Rails::Rack::Logger)
41
-
42
- # Probes only
43
- probes_only = Benchmark.measure("Timber probes only", &test)
44
- probes_only_per_req = probes_only.real / ITERATIONS
45
- probes_only_per_req_diff = probes_only_per_req - control_per_req
46
- log_line_count = line_count(io)
47
- probes_only_per_line = probes_only_per_req / log_line_count
48
-
49
- # Install Timber
50
- io = StringIO.new
51
- Support::Rails.set_timber_logger(io)
52
-
53
- # With timber logger
54
- with_timber = Benchmark.measure("Timber probes and logging", &test)
55
- with_timber_per_req = with_timber.real / ITERATIONS
56
- with_timber_per_req_diff = with_timber_per_req - probes_only_per_req
57
- log_line_count = line_count(io)
58
- with_timber_per_line = with_timber_per_req / log_line_count
59
-
60
- title = "Timber benchmarking. #{ITERATIONS} requests per test. Times are \"real\" CPU time."
61
- table = Terminal::Table.new(:title => title) do |t|
62
- t << [nil, "Total", "Per request avg", "Per log line"]
63
- t.add_separator
64
- t << [control.label, control.real.round(PRECISION), control_per_req.round(PRECISION), control_per_line.round(PRECISION)]
65
- t << [probes_only.label, probes_only.real.round(PRECISION), probes_only_per_req.round(PRECISION), probes_only_per_line.round(PRECISION)]
66
- t << [with_timber.label, with_timber.real.round(PRECISION), with_timber_per_req.round(PRECISION), with_timber_per_line.round(PRECISION)]
67
- end
68
- puts table