timber 2.6.2 → 3.0.0

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.
Files changed (142) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +8 -38
  3. data/CHANGELOG.md +9 -0
  4. data/README.md +30 -284
  5. data/Rakefile +78 -0
  6. data/lib/timber.rb +6 -6
  7. data/lib/timber/config.rb +1 -83
  8. data/lib/timber/config/integrations.rb +1 -47
  9. data/lib/timber/context.rb +3 -24
  10. data/lib/timber/contexts.rb +2 -30
  11. data/lib/timber/contexts/http.rb +16 -36
  12. data/lib/timber/contexts/release.rb +12 -23
  13. data/lib/timber/contexts/runtime.rb +9 -36
  14. data/lib/timber/contexts/session.rb +8 -21
  15. data/lib/timber/contexts/system.rb +9 -16
  16. data/lib/timber/contexts/user.rb +13 -33
  17. data/lib/timber/current_context.rb +16 -78
  18. data/lib/timber/event.rb +12 -9
  19. data/lib/timber/events.rb +1 -33
  20. data/lib/timber/events/controller_call.rb +20 -31
  21. data/lib/timber/events/error.rb +18 -26
  22. data/lib/timber/events/exception.rb +1 -0
  23. data/lib/timber/events/sql_query.rb +14 -24
  24. data/lib/timber/events/template_render.rb +13 -24
  25. data/lib/timber/integration.rb +1 -1
  26. data/lib/timber/integrator.rb +1 -1
  27. data/lib/timber/log_devices/http.rb +98 -19
  28. data/lib/timber/log_entry.rb +6 -24
  29. data/lib/timber/logger.rb +5 -14
  30. data/lib/timber/util.rb +1 -6
  31. data/lib/timber/util/non_nil_hash_builder.rb +3 -1
  32. data/lib/timber/version.rb +1 -1
  33. data/spec/README.md +2 -8
  34. data/spec/spec_helper.rb +0 -7
  35. data/spec/support/timber.rb +1 -3
  36. data/spec/timber/current_context_spec.rb +12 -50
  37. data/spec/timber/events/controller_call_spec.rb +4 -4
  38. data/spec/timber/events/error_spec.rb +4 -9
  39. data/spec/timber/log_devices/http_spec.rb +26 -2
  40. data/spec/timber/log_entry_spec.rb +12 -6
  41. data/spec/timber/logger_spec.rb +27 -68
  42. data/timber.gemspec +1 -1
  43. metadata +5 -139
  44. data/gemfiles/rails-3.0.gemfile +0 -5
  45. data/gemfiles/rails-3.1.gemfile +0 -5
  46. data/gemfiles/rails-3.2.gemfile +0 -5
  47. data/gemfiles/rails-4.0.gemfile +0 -9
  48. data/gemfiles/rails-4.1.gemfile +0 -9
  49. data/gemfiles/rails-4.2.gemfile +0 -9
  50. data/gemfiles/rails-5.0.gemfile +0 -9
  51. data/gemfiles/rails-5.1.gemfile +0 -9
  52. data/gemfiles/rails-edge.gemfile +0 -7
  53. data/lib/timber/cli.rb +0 -60
  54. data/lib/timber/cli/api.rb +0 -183
  55. data/lib/timber/cli/api/application.rb +0 -34
  56. data/lib/timber/cli/config_file.rb +0 -71
  57. data/lib/timber/cli/file_helper.rb +0 -53
  58. data/lib/timber/cli/installer.rb +0 -70
  59. data/lib/timber/cli/installers.rb +0 -102
  60. data/lib/timber/cli/installers/config_file.rb +0 -51
  61. data/lib/timber/cli/installers/other.rb +0 -59
  62. data/lib/timber/cli/installers/rails.rb +0 -225
  63. data/lib/timber/cli/installers/root.rb +0 -116
  64. data/lib/timber/cli/io.rb +0 -100
  65. data/lib/timber/cli/io/ansi.rb +0 -22
  66. data/lib/timber/cli/io/messages.rb +0 -198
  67. data/lib/timber/cli/os_helper.rb +0 -74
  68. data/lib/timber/config/integrations/rack.rb +0 -74
  69. data/lib/timber/contexts/custom.rb +0 -44
  70. data/lib/timber/contexts/organization.rb +0 -48
  71. data/lib/timber/events/custom.rb +0 -53
  72. data/lib/timber/events/http_request.rb +0 -71
  73. data/lib/timber/events/http_response.rb +0 -81
  74. data/lib/timber/frameworks.rb +0 -19
  75. data/lib/timber/frameworks/rails.rb +0 -27
  76. data/lib/timber/integrations.rb +0 -29
  77. data/lib/timber/integrations/action_controller.rb +0 -18
  78. data/lib/timber/integrations/action_controller/log_subscriber.rb +0 -27
  79. data/lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb +0 -46
  80. data/lib/timber/integrations/action_dispatch.rb +0 -23
  81. data/lib/timber/integrations/action_dispatch/debug_exceptions.rb +0 -53
  82. data/lib/timber/integrations/action_view.rb +0 -18
  83. data/lib/timber/integrations/action_view/log_subscriber.rb +0 -27
  84. data/lib/timber/integrations/action_view/log_subscriber/timber_log_subscriber.rb +0 -83
  85. data/lib/timber/integrations/active_record.rb +0 -18
  86. data/lib/timber/integrations/active_record/log_subscriber.rb +0 -26
  87. data/lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb +0 -53
  88. data/lib/timber/integrations/rack.rb +0 -27
  89. data/lib/timber/integrations/rack/error_event.rb +0 -64
  90. data/lib/timber/integrations/rack/http_context.rb +0 -27
  91. data/lib/timber/integrations/rack/http_events.rb +0 -210
  92. data/lib/timber/integrations/rack/middleware.rb +0 -28
  93. data/lib/timber/integrations/rack/session_context.rb +0 -65
  94. data/lib/timber/integrations/rack/user_context.rb +0 -135
  95. data/lib/timber/integrations/rails.rb +0 -22
  96. data/lib/timber/integrations/rails/rack_logger.rb +0 -60
  97. data/lib/timber/overrides.rb +0 -12
  98. data/lib/timber/overrides/active_support_3_tagged_logging.rb +0 -111
  99. data/lib/timber/overrides/active_support_buffered_logger.rb +0 -22
  100. data/lib/timber/overrides/active_support_tagged_logging.rb +0 -66
  101. data/lib/timber/overrides/lograge.rb +0 -18
  102. data/lib/timber/overrides/rails_stdout_logging.rb +0 -21
  103. data/lib/timber/util/active_support_log_subscriber.rb +0 -37
  104. data/lib/timber/util/attribute_normalizer.rb +0 -89
  105. data/lib/timber/util/hash.rb +0 -90
  106. data/lib/timber/util/request.rb +0 -72
  107. data/lib/timber/util/struct.rb +0 -16
  108. data/spec/rails/tagged_logging_spec.rb +0 -44
  109. data/spec/support/action_controller.rb +0 -8
  110. data/spec/support/active_record.rb +0 -32
  111. data/spec/support/rails.rb +0 -67
  112. data/spec/support/rails/templates/_partial.html +0 -1
  113. data/spec/support/rails/templates/template.html +0 -1
  114. data/spec/timber/cli/config_file_spec.rb +0 -26
  115. data/spec/timber/cli/installers/config_file_spec.rb +0 -36
  116. data/spec/timber/cli/installers/other_spec.rb +0 -49
  117. data/spec/timber/cli/installers/rails_spec.rb +0 -364
  118. data/spec/timber/cli/installers/root_spec.rb +0 -73
  119. data/spec/timber/config_spec.rb +0 -28
  120. data/spec/timber/contexts/custom_spec.rb +0 -11
  121. data/spec/timber/contexts/organization_spec.rb +0 -11
  122. data/spec/timber/contexts/runtime_spec.rb +0 -11
  123. data/spec/timber/contexts/system_spec.rb +0 -11
  124. data/spec/timber/contexts/user_spec.rb +0 -11
  125. data/spec/timber/contexts_spec.rb +0 -49
  126. data/spec/timber/event_spec.rb +0 -10
  127. data/spec/timber/events/custom_spec.rb +0 -36
  128. data/spec/timber/events/http_request_spec.rb +0 -32
  129. data/spec/timber/events/http_response_spec.rb +0 -12
  130. data/spec/timber/events_spec.rb +0 -55
  131. data/spec/timber/integrations/action_controller/log_subscriber_spec.rb +0 -55
  132. data/spec/timber/integrations/action_dispatch/debug_exceptions_spec.rb +0 -53
  133. data/spec/timber/integrations/action_view/log_subscriber_spec.rb +0 -115
  134. data/spec/timber/integrations/active_record/log_subscriber_spec.rb +0 -46
  135. data/spec/timber/integrations/rack/error_event_spec.rb +0 -63
  136. data/spec/timber/integrations/rack/http_context_spec.rb +0 -60
  137. data/spec/timber/integrations/rack/http_events_spec.rb +0 -101
  138. data/spec/timber/integrations/rack/session_context_spec.rb +0 -62
  139. data/spec/timber/integrations/rails/rack_logger_spec.rb +0 -58
  140. data/spec/timber/util/attribute_normalizer_spec.rb +0 -90
  141. data/spec/timber/util/hash_spec.rb +0 -30
  142. data/spec/timber/util/request_spec.rb +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fb990174a93469450d73ae20ffd997d61ca0f01e
4
- data.tar.gz: 0f7ada34254928c3b196b5e33ab5e7b11dbc3982
2
+ SHA256:
3
+ metadata.gz: 3a26e7b9b1e27e631deac9a62753d67fabfe532a37446c29ad532fc6948b5682
4
+ data.tar.gz: 66c38071146891f8d8e7a763a2486eda7d5aef7fdffbffb9a26dc8128a581e79
5
5
  SHA512:
6
- metadata.gz: 859c860cb28a5e11d6901ca8648e8e3467b43ac21131e4c33f5601883c8543427a21709f4f19827728ed0d0cddfe5ddfb176851109d69e5c4d8b3eb5ee11d701
7
- data.tar.gz: 10750c2cdd80151a56dee093f0c63e8180d4875235092e795a69ea1d459108e7f02f246251492267d1bacaf32ad1e3b36dc98e0db9dd4b696c2680b7518b7270
6
+ metadata.gz: 5acf7ca9461dd5b24b20cda20f7f6828e5f78c8fcb8cc44a3ef8a01ec882ba5fbcdec33f522d5753b4ef81a750c27820b33dbfb8d4cdd5eab80a299ce43bdece
7
+ data.tar.gz: e47f9313d14194be733203491d82213f87e5d1c2d5f2f6796a29e489dec892b6b699016a657147263e2658fd835f7836b64ed423fa6c882c1dd9171b8e2c51ee
@@ -3,23 +3,13 @@ language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
5
  - 1.9.3
6
- - 2.2.6
7
- - 2.3.3
8
- - 2.4.2
9
- - jruby-1.7.26
10
- - jruby-9.1.9.0
11
- gemfile:
12
- - gemfiles/rails-3.0.gemfile
13
- - gemfiles/rails-3.1.gemfile
14
- - gemfiles/rails-3.2.gemfile
15
- - gemfiles/rails-4.0.gemfile
16
- - gemfiles/rails-4.1.gemfile
17
- - gemfiles/rails-4.2.gemfile
18
- - gemfiles/rails-5.0.gemfile
19
- - gemfiles/rails-5.1.gemfile
20
- - gemfiles/rails-edge.gemfile
21
- env:
22
- global: RAILS_ENV=test
6
+ - 2.2.10
7
+ - 2.3.8
8
+ - 2.4.5
9
+ - 2.5.3
10
+ - jruby-1.7.27
11
+ - jruby-9.2.5.0
12
+ before_install: gem install bundler -v 1.17.3
23
13
  before_script:
24
14
  - echo $BUNDLE_GEMFILE
25
15
  - bundle install
@@ -27,27 +17,7 @@ script:
27
17
  - bundle exec rspec --format documentation
28
18
  matrix:
29
19
  fast_finish: true
30
- exclude:
31
- - rvm: 1.9.3
32
- - rvm: 2.2.6
33
- gemfile: gemfiles/rails-edge.gemfile
34
- - rvm: 2.3.3
35
- gemfile: gemfiles/rails-edge.gemfile
36
- include:
37
- - rvm: 1.9.3
38
- gemfile: gemfiles/rails-3.0.gemfile
39
- - rvm: 1.9.3
40
- gemfile: gemfiles/rails-3.1.gemfile
41
- - rvm: 1.9.3
42
- gemfile: gemfiles/rails-3.2.gemfile
43
- allow_failures:
44
- - rvm: 1.9.3 # bundler wont install the gems
45
- - rvm: 2.4.2
46
- gemfile: gemfiles/rails-4.0.gemfile
47
- - rvm: 2.4.2
48
- gemfile: gemfiles/rails-4.1.gemfile
49
- - rvm: jruby-1.7.26
50
- - rvm: jruby-9.1.9.0
20
+
51
21
  notifications:
52
22
  email: false
53
23
  slack:
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Changed
11
+
12
+ - Timber's Rails integration has been moved to the optional `timber_rails` gem: https://github.com/timberio/timber-ruby-rails
13
+ - Timber's Rack integration has been moved to the optional `timber_rack` gem: https://github.com/timberio/timber-ruby-rack
14
+ - Custom events are no longer nested under the `custom.event` key, events are now merged into the root docoment.
15
+ - Custom contexts are no longer nested under the `context.custom` key, contexts are not part of the top-level `context` document.
16
+ - The Timber JSON schema (`$shema` key) was dropped since the Timber.io service no longer requires a strict schema (structured data in any shape is accepted).
17
+ - `Timber::LogDevices::HTTP#initialize` now takes a second `source_id` parameter. Timber's new API keys are no longer Timber source specific and therefore require a `source_id` to be specificed. Ex: `Timber::LogDevices::HTTP.new('api_key', 'source_id')`.
18
+
10
19
  ## [2.6.2] - 2018-10-17
11
20
 
12
21
  ### Fixed
data/README.md CHANGED
@@ -1,299 +1,45 @@
1
1
  # 🌲 Timber - Great Ruby Logging Made Easy
2
2
 
3
+ <p align="center">
4
+ <a href="https://timber.io" target="_blank" align="center">
5
+ <img src="https://res.cloudinary.com/timber/image/upload/v1552328675/banner.jpg" width="900">
6
+ </a>
7
+ <br>
8
+ </p>
9
+
3
10
  [![ISC License](https://img.shields.io/badge/license-ISC-ff69b4.svg)](LICENSE.md)
4
11
  [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/timberio/timber-ruby)
5
12
  [![Build Status](https://travis-ci.org/timberio/timber-ruby.svg?branch=master)](https://travis-ci.org/timberio/timber-ruby)
6
13
  [![Code Climate](https://codeclimate.com/github/timberio/timber-ruby/badges/gpa.svg)](https://codeclimate.com/github/timberio/timber-ruby)
7
14
 
8
- Timber for Ruby is a drop in replacement for your Ruby logger that
9
- [unobtrusively augments](https://timber.io/docs/concepts/structuring-through-augmentation) your
10
- logs with [rich metadata and context](https://timber.io/docs/concepts/metadata-context-and-events)
11
- making them [easier to search, use, and read](#get-things-done-with-your-logs). It pairs with the
12
- [Timber console](#the-timber-console) to deliver a tailored Ruby logging experience designed to make
13
- you more productive.
14
-
15
- 1. [**Installation** - One command: `bundle exec timber install`](#installation)
16
- 2. [**Usage** - Simple & powerful API](#usage)
17
- 3. [**Integrations** - Automatic context and metadata for your existing logs](#integrations)
18
- 4. [**The Timber Console** - Designed for applications & developers](#the-timber-console)
19
- 5. [**Get things done with your logs 💪**](#get-things-done-with-your-logs)
20
-
21
-
22
- ## Installation
23
-
24
- 1. In your `Gemfile`, add the `timber` gem:
25
-
26
- ```ruby
27
- gem 'timber', '~> 2.3'
28
- ```
29
-
30
- 2. In your `shell`, run:
31
-
32
- ```
33
- bundle install && bundle exec timber install
34
- ```
35
-
36
-
37
- ## Usage
38
-
39
- <details><summary><strong>Basic logging</strong></summary><p>
15
+ [Timber.io](https://timber.io) is a hosted service for aggregating logs across your entire stack -
16
+ [any language](https://docs.timber.io/setup/languages),
17
+ [any platform](https://docs.timber.io/setup/platforms),
18
+ [any data source](https://docs.timber.io/setup/log_forwarders).
40
19
 
41
- Use the `Timber::Logger` just like you would `::Logger`:
42
-
43
- ```ruby
44
- logger.debug("Debug message")
45
- logger.info("Info message")
46
- logger.warn("Warn message")
47
- logger.error("Error message")
48
- logger.fatal("Fatal message")
49
- ```
50
-
51
- * [Search it](https://timber.io/docs/app/console/searching) with queries like: `error message`
52
- * [Alert on it](https://timber.io/docs/app/console/alerts) with threshold based alerts
53
- * [View this event's metadata and context](https://timber.io/docs/app/console/view-metadata-and-context)
54
-
55
- [...read more in our docs](https://timber.io/docs/languages/ruby/usage/basic-logging)
56
-
57
- ---
58
-
59
- </p></details>
60
-
61
- <details><summary><strong>Logging events (structured data)</strong></summary><p>
62
-
63
- Log structured data without sacrificing readability:
64
-
65
- ```ruby
66
- logger.warn "Payment rejected", payment_rejected: {customer_id: "abcd1234", amount: 100, reason: "Card expired"}
67
- ```
68
-
69
- * [Search it](https://timber.io/docs/app/console/searching) with queries like: `type:payment_rejected` or `payment_rejected.amount:>100`
70
- * [Alert on it](https://timber.io/docs/app/console/alerts) with threshold based alerts
71
- * [View this event's data and context](https://timber.io/docs/app/console/view-metadata-and-context)
72
-
73
- ...[read more in our docs](https://timber.io/docs/languages/ruby/usage/custom-events)
20
+ Unlike traditional logging tools, Timber integrates with language runtimes to automatically
21
+ capture in-app context, turning your text-based logs into rich structured events.
22
+ Timber integrates with Ruby through this library. And Timber's
23
+ [rich free-form query tools](https://docs-new.timber.io/usage/live-tailing#query-syntax) and
24
+ [real-time tailing](https://docs-new.timber.io/usage/live-tailing), make drilling down into
25
+ important stats easier than ever.
74
26
 
75
27
  ---
76
28
 
77
- </p></details>
78
-
79
- <details><summary><strong>Setting context</strong></summary><p>
80
-
81
- Add shared structured data across your logs:
82
-
83
- ```ruby
84
- Timber.with_context(job: {id: 123}) do
85
- logger.info("Background job execution started")
86
- # ... code here
87
- logger.info("Background job execution completed")
88
- end
89
- ```
90
-
91
- * [Search it](https://timber.io/docs/app/console/searching) with queries like: `job.id:123`
92
- * [View this context when viewing a log's metadata](https://timber.io/docs/app/console/view-metadata-and-context)
93
-
94
- ...[read more in our docs](https://timber.io/docs/languages/ruby/usage/custom-context)
29
+ * **[Features](https://docs.timber.io/setup/languages/ruby#features)**
30
+ * **[Installation](https://docs.timber.io/setup/languages/ruby#installation)**
31
+ * **[Configuration](https://docs.timber.io/setup/languages/ruby#configuration)**
32
+ * **[Usage](https://docs.timber.io/setup/languages/ruby#usage)**
33
+ * **[Guides](https://docs.timber.io/setup/languages/ruby#guides)**
34
+ * **[Integrations](https://docs.timber.io/setup/languages/ruby/integrations)**
35
+ * **[Performance](https://docs.timber.io/setup/languages/ruby#performance)**
95
36
 
96
37
  ---
97
38
 
98
- </p></details>
99
-
100
- <details><summary><strong>Metrics, Timings, & Tracing</strong></summary><p>
101
-
102
- Time code blocks:
103
-
104
- ```ruby
105
- timer = Timber.start_timer
106
- # ... code to time ...
107
- logger.info("Processed background job", background_job: {time_ms: timer})
108
- ```
109
-
110
- Log generic metrics:
111
-
112
- ```ruby
113
- logger.info("Credit card charged", credit_card_charge: {amount: 123.23})
114
- ```
115
-
116
- * [Search it](https://timber.io/docs/app/console/searching) with queries like: `background_job.time_ms:>500`
117
- * [Alert on it](https://timber.io/docs/app/console/alerts) with threshold based alerts
118
- * [View this log's metadata in the console](https://timber.io/docs/app/console/view-metadata-and-context)
119
-
120
- ...[read more in our docs](https://timber.io/docs/languages/ruby/usage/metrics-and-timings)
121
-
122
- </p></details>
123
-
124
-
125
- ## Configuration
126
-
127
- Below are a few popular configuration options, for a comprehensive list, see
128
- [Timber::Config](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Config).
129
-
130
- <details><summary><strong>Logrageify. Silence noisy logs.</strong></summary><p>
131
-
132
- Silence noisy logs that aren't of value to you, just like
133
- [lograge](https://github.com/roidrage/lograge):
134
-
135
- ```ruby
136
- # config/initializers/timber.rb
137
- Timber.config.logrageify!()
138
- ```
139
-
140
- It turns this:
141
-
142
- ```
143
- Started GET "/" for 127.0.0.1 at 2012-03-10 14:28:14 +0100
144
- Processing by HomeController#index as HTML
145
- Rendered text template within layouts/application (0.0ms)
146
- Rendered layouts/_assets.html.erb (2.0ms)
147
- Rendered layouts/_top.html.erb (2.6ms)
148
- Rendered layouts/_about.html.erb (0.3ms)
149
- Rendered layouts/_google_analytics.html.erb (0.4ms)
150
- Completed 200 OK in 79ms (Views: 78.8ms | ActiveRecord: 0.0ms)
151
- ```
152
-
153
- Into this:
154
-
155
- ```
156
- Get "/" sent 200 OK in 79ms
157
- ```
158
-
159
- ### Pro-tip: Keep controller call logs (recommended)
160
-
161
- Feel free to deviate and customize which logs you silence. We recommend a slight deviation
162
- from lograge with the following settings:
163
-
164
- ```ruby
165
- # config/initializers/timber.rb
166
-
167
- Timber.config.integrations.action_view.silence = true
168
- Timber.config.integrations.active_record.silence = true
169
- Timber.config.integrations.rack.http_events.collapse_into_single_event = true
170
- ```
171
-
172
- This does _not_ silence the controller call log event. This is because Timber captures the
173
- parameters passed to the controller, which are generally valuable when debugging.
174
-
175
- For a full list of integration settings, see
176
- [Timber::Config::Integrations](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Config/Integrations)
177
-
178
- ---
179
-
180
- </p></details>
181
-
182
- <details><summary><strong>Silence specific requests (LB health checks, etc)</strong></summary><p>
183
-
184
- Silencing noisy requests can be helpful for silencing load balance health checks, bot scanning,
185
- or activity that generally is not meaningful to you. The following will silence all
186
- `[GET] /_health` requests:
187
-
188
- ```ruby
189
- # config/initializers/timber.rb
190
-
191
- Timber.config.integrations.rack.http_events.silence_request = lambda do |rack_env, rack_request|
192
- rack_request.path == "/_health"
193
- end
194
- ```
195
-
196
- We require a block because it gives you complete control over how you want to silence requests.
197
- The first parameter being the traditional Rack env hash, the second being a
198
- [Rack Request](http://www.rubydoc.info/gems/rack/Rack/Request) object.
199
-
200
- ---
201
-
202
- </p></details>
203
-
204
- <details><summary><strong>Capture custom user context</strong></summary><p>
205
-
206
- By default Timber automatically captures user context for most of the popular authentication
207
- libraries (Devise, and Clearance). See
208
- [Timber::Integrations::Rack::UserContext](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Integrations/Rack/UserContext)
209
- for a complete list.
210
-
211
- In cases where you Timber doesn't support your strategy, or you want to customize it further,
212
- you can do so like:
213
-
214
- ```ruby
215
- # config/initializers/timber.rb
216
-
217
- Timber.config.integrations.rack.user_context.custom_user_hash = lambda do |rack_env|
218
- user = rack_env['warden'].user
219
- if user
220
- {
221
- id: user.id, # unique identifier for the user, can be an integer or string,
222
- name: user.name, # identifiable name for the user,
223
- email: user.email, # user's email address
224
- }
225
- else
226
- nil
227
- end
228
- end
229
- ```
230
-
231
- *All* of the user hash keys are optional, but you must provide at least one.
232
-
233
- ---
234
-
235
- </p></details>
236
-
237
- <details><summary><strong>Capture release / deploy context</strong></summary><p>
238
-
239
- [Timber::Contexts::Release](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Contexts/Release)
240
- tracks the current application release and version.
241
-
242
- If you're on Heroku, simply enable the
243
- [dyno metadata](https://devcenter.heroku.com/articles/dyno-metadata) feature. If you are not,
244
- set the following environment variables and this context will be added automatically:
245
-
246
- 1. `RELEASE_COMMIT` - Ex: `2c3a0b24069af49b3de35b8e8c26765c1dba9ff0`
247
- 2. `RELEASE_CREATED_AT` - Ex: `2015-04-02T18:00:42Z`
248
- 3. `RELEASE_VERSION` - Ex: `v2.3.1`
249
-
250
- All variables are optional, but at least one must be present.
251
-
252
- ---
253
-
254
- </p></details>
255
-
256
-
257
- ## Integrations
258
-
259
- Timber integrates with popular frameworks and libraries to capture context and metadata you
260
- couldn't otherwise. This automatically augments logs produced by these libraries, making them
261
- [easier to search and use](#do-amazing-things-with-your-logs). Below is a list of libraries we
262
- support:
263
-
264
- * Frameworks & Libraries
265
- * [**Rails**](https://timber.io/docs/languages/ruby/integrations/rails)
266
- * [**Rack**](https://timber.io/docs/languages/ruby/integrations/rack)
267
- * [**Devise**](https://timber.io/docs/languages/ruby/integrations/devise)
268
- * [**Clearance**](https://timber.io/docs/languages/ruby/integrations/clearnace)
269
- * [**Warden**](https://timber.io/docs/languages/ruby/integrations/devise)
270
- * Platforms
271
- * [**Heroku**](https://timber.io/docs/languages/ruby/integrations/heroku)
272
- * [**System / Server**](https://timber.io/docs/languages/ruby/integrations/system)
273
-
274
- ...more coming soon! Make a request by [opening an issue](https://github.com/timberio/timber-ruby/issues/new)
275
-
276
-
277
- ## Get things done with your logs
278
-
279
- Logging features designed to help developers get more done:
280
-
281
- 1. [**Powerful searching.** - Find what you need faster.](https://timber.io/docs/app/console/searching)
282
- 2. [**Live tail users.** - Easily solve customer issues.](https://timber.io/docs/app/console/tail-a-user)
283
- 3. [**View logs per HTTP request.** - See the full story without the noise.](https://timber.io/docs/app/console/trace-http-requests)
284
- 4. [**Inspect HTTP request parameters.** - Quickly reproduce issues.](https://timber.io/docs/app/console/inspect-http-requests)
285
- 5. [**Threshold based alerting.** - Know when things break.](https://timber.io/docs/app/alerts)
286
- 6. ...and more! Checkout our [the Timber application docs](https://timber.io/docs/app)
287
-
288
-
289
- ## The Timber Console
290
-
291
- [![Timber Console](http://files.timber.io/images/readme-interface7.gif)](https://timber.io/docs/app)
292
-
293
- [Learn more about our app.](https://timber.io/docs/app)
294
-
295
- ## Your Moment of Zen
296
-
297
- <p align="center" style="background: #221f40;">
298
- <a href="https://timber.io"><img src="http://files.timber.io/images/readme-log-truth.png" height="947" /></a>
39
+ <p align="center">
40
+ <a href="https://timber.io">Timber</a> &bull;
41
+ <a href="https://docs.timber.io">Docs</a> &bull;
42
+ <a href="https://timber.io/pricing">Pricing</a> &bull;
43
+ <a href="https://timber.io/terms">Security</a> &bull;
44
+ <a href="https://timber.io/privacy">Compliance</a>
299
45
  </p>
@@ -0,0 +1,78 @@
1
+ require "bundler/gem_tasks"
2
+ require "timber"
3
+
4
+ def puts_with_level(message, level = :info)
5
+ case level
6
+ when :info
7
+ puts("\e[31m#{message}\e[0m")
8
+ when :error
9
+ puts("\e[31m#{message}\e[0m")
10
+ when :success
11
+ puts("\e[32m#{message}\e[0m")
12
+ else
13
+ puts(message)
14
+ end
15
+ end
16
+
17
+ task :test_the_pipes, [:api_key] do |t, args|
18
+ support_email = "support@timber.io"
19
+ # Do not modify below this line. It's important to keep the `Timber::Logger`
20
+ # because it provides an API for logging structured data and capturing context.
21
+ header = <<-HEREDOC
22
+ ^ ^ ^ ^ ^ ^ ___I_ ^ ^ ^ ^ ^ ^ ^
23
+ /|\\/|\\ /|\\/|\\/|\\ /|\\ /\\-_--\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\
24
+ /|\\/|\\ /|\\/|\\/|\\ /|\\ / \\_-__\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\
25
+ /|\\/|\\ /|\\/|\\/|\\ /|\\ |[]| [] | /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\
26
+ ============================================================
27
+ TIMBER.IO - TESTING THE PIPES
28
+ ============================================================
29
+ HEREDOC
30
+
31
+ puts header
32
+
33
+ current_context = Timber::CurrentContext.instance.snapshot
34
+ entry = Timber::LogEntry.new(:info, Time.now, nil, "Testing the pipes (click the inspect icon to view more details)", current_context, nil)
35
+ http_device = Timber::LogDevices::HTTP.new(args.api_key, flush_continuously: false)
36
+ response = http_device.deliver_one(entry)
37
+ if response.is_a?(Exception)
38
+ message = <<~HEREDOC
39
+ Unable to deliver logs.
40
+ Here's what we received from the Timber API:
41
+ #{response.inspect}
42
+ If you continue to have trouble please contact support:
43
+ #{support_email}
44
+ HEREDOC
45
+ puts_with_level(message, :error)
46
+ elsif response.is_a?(Net::HTTPResponse)
47
+ if response.code.start_with? '2'
48
+ puts_with_level("Logs successfully sent! View them at https://app.timber.io",
49
+ :success)
50
+ else
51
+ message =
52
+ <<~HEREDOC
53
+ Unable to deliver logs.
54
+ We received a #{response.code} response from the Timber API:
55
+ #{response.body.inspect}
56
+ If you continue to have trouble please contact support:
57
+ #{support_email}
58
+ HEREDOC
59
+ puts_with_level(message, :error)
60
+ end
61
+ end
62
+ end
63
+
64
+ task :console do
65
+ require 'irb'
66
+ require 'irb/completion'
67
+ require 'timber'
68
+ $VERBOSE = nil
69
+
70
+ def reload!
71
+ files = $LOADED_FEATURES.select { |feat| feat =~ /\/timber\// }
72
+ files.each { |file| load file }
73
+ "reloaded"
74
+ end
75
+
76
+ ARGV.clear
77
+ IRB.start
78
+ end