timber 2.1.3 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 551b1cf8e53fd0ba73e513e32377ad3d6113dfed
4
- data.tar.gz: 7f701ccda19d0ba463605a217f59433484303206
3
+ metadata.gz: 8abcf84c32b728be216520c831ea391b2d8d4aff
4
+ data.tar.gz: bd66dceece6b234a4de867656eeaeebeb5c9a7a5
5
5
  SHA512:
6
- metadata.gz: 2bf3d315d1f5d9a8bcfdbc4020fc712e709e7d74ddb4223e50b8f15b7dbaecfc4a068621282dbfe05c198d2b08e6704fafc1feae5ab7f798ed59de4f3a6d8c76
7
- data.tar.gz: 2186c8a2d25d2d06f47af2f4b6093c0b1d364ada661b7c965387e91978323211e6387cbb078550f1ab1c29716351e9f832465acc948ffaa287f55e044ab4be15
6
+ metadata.gz: 71850c881fe047e8e80f850010f99989b0206be96087cbf15ff84adb09b6d9780b062ba492e65c2fffd659bd2d013c12f6e2b829c60847d0e750ae56f9d6268d
7
+ data.tar.gz: 27c4421fcfa563a47d6d92911effde2472a3e48b4ba5da9b7def6ee3fa031f1bcc2d3a9cd54da88a3aa13db1f0a19e5556eb6d5c84fba4394aa62f28ab353c54
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # 🌲 Timber - Log Better. Solve Problems Faster.
1
+ # 🌲 Timber - Great Ruby Logging Made Easy
2
2
 
3
3
  [![ISC License](https://img.shields.io/badge/license-ISC-ff69b4.svg)](LICENSE.md)
4
4
  [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/timberio/timber-ruby)
@@ -6,14 +6,15 @@
6
6
 
7
7
  ## Overview
8
8
 
9
- Timber for Ruby is an drop-in replacement for your ruby `Logger` that transparently augments your
10
- logs with critical metadata and context. It's structured logging without all of the noise; turning
11
- your logs into rich, useful, readable events. When paired with the
12
- [Timber console](#the-timber-console), Timber will fundamentally change the way you use your logs.
9
+ Timber for Ruby is a drop-in upgrade for your Ruby logs that unobtrusively
10
+ [structures your logs through augmentation](https://timber.io/docs/concepts/structuring-through-augmentation).
11
+ It's clean structured logging without the effort. When paired with the
12
+ [Timber console](#the-timber-console), Timber will
13
+ [fundamentally change the way you use your logs](#do-amazing-things-with-your-logs).
13
14
 
14
15
  1. [**Easy setup** - `bundle exec timber install`](#installation)
15
- 2. [**Seamlessly integrates with popular libraries and frameworks**](#jibber-jabber)
16
- 3. [**Modern fast console, designed for Ruby application logging**](#the-timber-console)
16
+ 2. [**Seamlessly integrates with popular libraries and frameworks**](#integrations)
17
+ 3. [**Do amazing things with your Ruby logs**](#do-amazing-things-with-your-logs)
17
18
 
18
19
 
19
20
  ## Installation
@@ -36,29 +37,39 @@ your logs into rich, useful, readable events. When paired with the
36
37
  Use the `Timber::Logger` just like you would `::Logger`:
37
38
 
38
39
  ```ruby
39
- logger.info("My log message") # use warn, error, debug, etc.
40
-
41
- # => My log message @metadata {"level": "info", "context": {...}}
40
+ logger.debug("Debug message")
41
+ logger.info("Info message")
42
+ logger.warn("Warn message")
43
+ logger.error("Error message")
44
+ logger.fatal("Fatal message")
42
45
  ```
43
46
 
47
+ We encourage standard / traditional log messages for non-meaningful events. And because Timber
48
+ [augments](https://timber.io/docs/concepts/structuring-through-augmentation) your logs with
49
+ metadata, you don't have to worry about making every log structured!
50
+
44
51
  ---
45
52
 
46
53
  </p></details>
47
54
 
48
55
  <details><summary><strong>Custom events</strong></summary><p>
49
56
 
50
- Custom events allow you to extend beyond events already defined in
51
- the [`Timber::Events`](lib/timber/events) namespace.
57
+ Custom events allow you to extend beyond events already defined in the
58
+ [`Timber::Events`](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Events) namespace.
59
+ If you aren't sure what an event is, please read the
60
+ ["Metdata, Context, and Events" doc](https://timber.io/docs/concepts/metadata-context-and-events).
61
+
62
+ ### How to use it
52
63
 
53
64
  ```ruby
54
65
  logger.warn "Payment rejected", payment_rejected: {customer_id: "abcd1234", amount: 100, reason: "Card expired"}
55
-
56
- # => Payment rejected @metadata {"level": "warn", "event": {"payment_rejected": {"customer_id": "abcd1234", "amount": 100, "reason": "Card expired"}}, "context": {...}}
57
66
  ```
58
67
 
59
- * Notice the `:payment_rejected` root key. Timber will classify this event as such.
60
- * In the [Timber console](https://app.timber.io) use the query: `type:payment_rejected` or `payment_rejected.amount:>100`.
61
- * See more details on our [custom events docs page](https://timber.io/docs/ruby/usage/custom-events/)
68
+ 1. [Search it](https://timber.io/docs/app/console/searching) with queries like: `type:payment_rejected` or `payment_rejected.amount:>100`
69
+ 2. [Alert on it](https://timber.io/docs/app/console/alerts) with threshold based alerts
70
+ 3. [Graph & visualize it](https://timber.io/docs/app/console/graphing)
71
+ 4. [View this event's data and context](https://timber.io/docs/app/console/view-metdata-and-context)
72
+ 5. ...read more in our [docs](https://timber.io/docs/languages/ruby/usage/custom-events)
62
73
 
63
74
  ---
64
75
 
@@ -66,22 +77,22 @@ logger.warn "Payment rejected", payment_rejected: {customer_id: "abcd1234", amou
66
77
 
67
78
  <details><summary><strong>Custom contexts</strong></summary><p>
68
79
 
69
- Context is additional data shared across log lines. Think of it like log join data.
70
- This is how a query like `context.user.id:1` can show you all logs generated by that user.
71
80
  Custom contexts allow you to extend beyond contexts already defined in
72
- the [`Timber::Contexts`](lib/timber/contexts) namespace.
81
+ the [`Timber::Contexts`](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Contexts)
82
+ namespace. If you aren't sure what context is, please read the
83
+ ["Metdata, Context, and Events" doc](https://timber.io/docs/concepts/metadata-context-and-events).
84
+
85
+ ### How to use it
73
86
 
74
87
  ```ruby
75
88
  logger.with_context(build: {version: "1.0.0"}) do
76
89
  logger.info("My log message")
77
90
  end
78
-
79
- # => My log message @metadata {"level": "info", "context": {"build": {"version": "1.0.0"}}}
80
91
  ```
81
92
 
82
- * Notice the `:build` root key. Timber will classify this context as such.
83
- * In the [Timber console](https://app.timber.io) use queries like: `build.version:1.0.0`
84
- * See more details on our [custom contexts docs page](https://timber.io/docs/ruby/usage/custom-contexts/)
93
+ 1. [Search it](https://timber.io/docs/app/console/searching) with queries like: `build.version:1.0.0`
94
+ 2. [View this context when viewing a log's metadata](https://timber.io/docs/app/console/view-metdata-and-context)
95
+ 3. ...read more in our [docs](https://timber.io/docs/languages/ruby/usage/custom-context)
85
96
 
86
97
  ---
87
98
 
@@ -89,20 +100,21 @@ end
89
100
 
90
101
  <details><summary><strong>Metrics & Timings</strong></summary><p>
91
102
 
92
- Aggregates destroy details, and with Timber capturing metrics and timings is just logging events.
93
- Timber is built on modern big-data principles, it can calculate aggregates across terrabytes of
94
- data in seconds. Don't reduce the quality of your log data to accomodate a restrive
95
- logging system.
103
+ Aggregates destroy details, events tell stories. With Timber, logging metrics and timings is simply
104
+ [logging an event](https://timber.io/docs/languages/ruby/usage/custom-events). Timber is based on
105
+ modern big-data principles and can aggregate inordinately large data sets in seconds. Logging
106
+ events (raw data as it exists), gives you the flexibility in the future to segment and aggregate
107
+ your data any way you see fit. This is superior to choosing specific paradigms before hand, when
108
+ you are unsure how you'll need to use your data in the future.
109
+
110
+ ### How to use it
96
111
 
97
- Here's a timing example. Notice how Timber automatically calculates the time and adds the timing
98
- to the message.
112
+ Below is a contrived example of timing a background job:
99
113
 
100
114
  ```ruby
101
115
  timer = Timber::Timer.start
102
116
  # ... code to time ...
103
117
  logger.info("Processed background job", background_job: {time_ms: timer})
104
-
105
- # => Processed background job in 54.2ms @metadata {"level": "info", "event": {"background_job": {"time_ms": 54.2}}}
106
118
  ```
107
119
 
108
120
  And of course, `time_ms` can also take a `Float` or `Fixnum`:
@@ -115,12 +127,13 @@ Lastly, metrics aren't limited to timings. You can capture any metric you want:
115
127
 
116
128
  ```ruby
117
129
  logger.info("Credit card charged", credit_card_charge: {amount: 123.23})
118
-
119
- # => Credit card charged @metadata {"level": "info", "event": {"credit_card_charge": {"amount": 123.23}}}
120
130
  ```
121
131
 
122
- In Timber you can easily sum, average, min, and max the `amount` attribute across any interval
123
- you desire.
132
+ 1. [Search it](https://timber.io/docs/app/console/searching) with queries like: `background_job.time_ms:>500`
133
+ 2. [Alert on it](https://timber.io/docs/app/console/alerts) with threshold based alerts
134
+ 3. [View this log's metadata in the console](https://timber.io/docs/app/console/view-metdata-and-context)
135
+ 4. ...read more in our [docs](https://timber.io/docs/languages/ruby/usage/metrics-and-timings)
136
+
124
137
 
125
138
  </p></details>
126
139
 
@@ -130,11 +143,13 @@ you desire.
130
143
  Below are a few popular configuration options, for a comprehensive list, see
131
144
  [Timber::Config](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Config).
132
145
 
133
- <details><summary><strong>Logrageify. Silence noisy logs (sql query, template renders)</strong></summary><p>
146
+ <details><summary><strong>Logrageify. Silence noisy logs.</strong></summary><p>
134
147
 
135
148
  Timber allows you to silence noisy logs that aren't of value to you, just like
136
- [lograge](https://github.com/roidrage/lograge). In fact, we've provided a convenience method
137
- for anyone transitioning from lograge:
149
+ [lograge](https://github.com/roidrage/lograge). As such, we've provided a convenience configuration
150
+ option for anyone transitioning from lograge.
151
+
152
+ ### How to use it
138
153
 
139
154
  ```ruby
140
155
  # config/initializers/timber.rb
@@ -143,6 +158,8 @@ config = Timber::Config.instance
143
158
  config.logrageify!()
144
159
  ```
145
160
 
161
+ ## How it works
162
+
146
163
  It turns this:
147
164
 
148
165
  ```
@@ -174,6 +191,8 @@ config.integrations.active_record.silence = true
174
191
  config.integrations.rack.http_events.collapse_into_single_event = true
175
192
  ```
176
193
 
194
+ ### Pro-tip: Keep controller call logs (recommended)
195
+
177
196
  Feel free to deviate and customize which logs you silence. We recommend a slight deviation
178
197
  from lograge with the following settings:
179
198
 
@@ -198,6 +217,11 @@ For a full list of integration settings, see
198
217
 
199
218
  <details><summary><strong>Silence specific requests (LB health checks, etc)</strong></summary><p>
200
219
 
220
+ Silencing noisy requests can be helpful for silencing load balance health checks, bot scanning,
221
+ or activity that generally is not meaningful to you.
222
+
223
+ ### How to use it
224
+
201
225
  The following will silence all `[GET] /_health` requests:
202
226
 
203
227
  ```ruby
@@ -217,33 +241,6 @@ The first parameter being the traditional Rack env hash, the second being a
217
241
 
218
242
  </p></details>
219
243
 
220
- <details><summary><strong>Change log formats</strong></summary><p>
221
-
222
- Simply set the formatter like you would with any other logger:
223
-
224
- ```ruby
225
- # This is set in your various environment files
226
- logger.formatter = Timber::Logger::JSONFormatter.new
227
- ```
228
-
229
- Your options are:
230
-
231
- 1. [`Timber::Logger::AugmentedFormatter`](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Logger/AugmentedFormatter) -
232
- (default) A human readable format that _appends_ metadata to the original log line. The Timber
233
- service can parse this data appropriately.
234
- Ex: `My log message @metadata {"level":"info","dt":"2017-01-01T01:02:23.234321Z"}`
235
-
236
- 2. [`Timber::Logger::JSONFormatter`](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Logger/JSONFormatter) -
237
- Ex: `{"level":"info","message":"My log message","dt":"2017-01-01T01:02:23.234321Z"}`
238
-
239
- 3. [`Timber::Logger::MessageOnlyFormatter`](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Logger/MessageOnlyFormatter) -
240
- For use in development / test. Prints logs as strings with no metadata attached.
241
- Ex: `My log message`
242
-
243
- ---
244
-
245
- </p></details>
246
-
247
244
  <details><summary><strong>Capture custom user context</strong></summary><p>
248
245
 
249
246
  By default Timber automatically captures user context for most of the popular authentication
@@ -251,6 +248,8 @@ libraries (Devise, Omniauth, and Clearance). See
251
248
  [Timber::Integrations::Rack::UserContext](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Integrations/Rack/UserContext)
252
249
  for a complete list.
253
250
 
251
+ ### How to use it
252
+
254
253
  In cases where you Timber doesn't support your strategy, or you want to customize it further,
255
254
  you can do so like:
256
255
 
@@ -281,7 +280,11 @@ end
281
280
  <details><summary><strong>Capture release / deploy context</strong></summary><p>
282
281
 
283
282
  [Timber::Contexts::Release](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Contexts/Release)
284
- tracks the current application release and version. If you're on Heroku, simply enable the
283
+ tracks the current application release and version.
284
+
285
+ ### How to use it
286
+
287
+ If you're on Heroku, simply enable the
285
288
  [dyno metadata](https://devcenter.heroku.com/articles/dyno-metadata) feature. If you are not,
286
289
  set the following environment variables and this context will be added automatically:
287
290
 
@@ -296,70 +299,44 @@ All variables are optional, but at least one must be present.
296
299
  </p></details>
297
300
 
298
301
 
299
- ## Jibber-Jabber
300
-
301
- <details><summary><strong>Which log events does Timber structure for me?</strong></summary><p>
302
-
303
- Out of the box you get everything in the [`Timber.Events`](lib/timber/events) namespace.
304
-
305
- We also add context to every log, everything in the [`Timber.Contexts`](lib/timber/contexts)
306
- namespace. Context is structured data representing the current environment when the log line
307
- was written. It is included in every log line. Think of it like join data for your logs.
308
-
309
- ---
310
-
311
- </p></details>
312
-
313
- <details><summary><strong>What about my current log statements?</strong></summary><p>
314
-
315
- They'll continue to work as expected. Timber adheres strictly to the default `Logger` interface
316
- and will never deviate in *any* way.
302
+ ## Integrations
317
303
 
318
- In fact, traditional log statements for non-meaningful events, debug statements, etc, are
319
- encouraged. In cases where the data is meaningful, consider [logging a custom event](#usage).
304
+ [Timber for Ruby](https://github.com/timberio/timber-ruby) extends beyond your basic logging
305
+ functionality and integrates with popular libraries and frameworks. This makes structured quality
306
+ logging effortless. Below is a list of integrations we offer and the various events and contexts
307
+ they create.
320
308
 
321
- </p></details>
309
+ 1. [**Rails**](https://timber.io/docs/languages/ruby/integrations/rails)
310
+ 2. [**Rack**](https://timber.io/docs/languages/ruby/integrations/rack)
311
+ 3. [**Heroku**](https://timber.io/docs/languages/ruby/integrations/heroku)
312
+ 4. [**Devise**](https://timber.io/docs/languages/ruby/integrations/devise)
313
+ 5. [**Clearance**](https://timber.io/docs/languages/ruby/integrations/clearnace)
314
+ 6. [**Omniauth**](https://timber.io/docs/languages/ruby/integrations/omniauth)
315
+ 7. [**Warden**](https://timber.io/docs/languages/ruby/integrations/devise)
316
+ 8. ...more coming soon! Make a request by [opening an issue](https://github.com/timberio/timber-ruby/issues/new)
322
317
 
323
- <details><summary><strong>When to use metadata or events?</strong></summary><p>
324
318
 
325
- At it's basic level, both metadata and events serve the same purpose: they add structured
326
- data to your logs. And anyone that's implemented structured logging know's this can quickly get
327
- out of hand. This is why we created events. Here's how we recommend using them:
319
+ ## Do amazing things with your logs
328
320
 
329
- 1. Use `events` when the log cleanly maps to an event that you'd like to alert on, graph, or use
330
- in a meaningful way. Typically something that is core to your business or application.
331
- 2. Use metadata for debugging purposes; when you simply want additional insight without
332
- polluting the message.
321
+ What does all of this mean? Doing amazing things with your logs! Being more productive, solving
322
+ problems faster, and _actually_ enjoying using your logs for application insight:
333
323
 
334
- ### Example 1: Logging that a payment was rejected
335
-
336
- This is clearly an event that is meaningful to your business. You'll probably want to alert and
337
- graph this data. So let's log it as an official event:
338
-
339
- ```ruby
340
- logger.info("Payment rejected", payment_rejected: {customer_id: "xiaus1934", amount: 1900, currency: "USD"})
341
- ```
342
-
343
- ### Example 2: Logging that an email was changed
344
-
345
- This is definitely log worthy, but not something that is core to your business or application.
346
- Instead of an event, use metadata:
347
-
348
- ```ruby
349
- logger.info("Email successfully changed", old_email: old_email, new_email: new_email)
350
- ```
351
-
352
- ---
353
-
354
- </p></details>
324
+ 1. [**Live tail users on your app**](https://timber.io/docs/app/console/tail-a-user)
325
+ 2. [**Trace HTTP requests**](https://timber.io/docs/app/console/trace-http-requests)
326
+ 3. [**Inspect HTTP request parameters**](https://timber.io/docs/app/console/inspect-http-requests)
327
+ 4. [**Powerful searching**](https://timber.io/docs/app/console/searching)
328
+ 5. [**Threshold based alerting**](https://timber.io/docs/app/alerts)
329
+ 6. ...and more! Checkout our [the Timber application docs](https://timber.io/docs/app)
355
330
 
356
331
 
357
332
  ## The Timber Console
358
333
 
359
- [![Timber Console](http://files.timber.io/images/readme-interface7.gif)](https://app.timber.io)
334
+ [![Timber Console](http://files.timber.io/images/readme-interface7.gif)](https://timber.io/docs/app)
335
+
336
+ [Learn more about our app.](https://timber.io/docs/app)
360
337
 
361
338
  ## Your Moment of Zen
362
339
 
363
340
  <p align="center" style="background: #221f40;">
364
- <a href="http://github.com/timberio/timber-ruby"><img src="http://files.timber.io/images/readme-log-truth.png" height="947" /></a>
341
+ <a href="https://timber.io"><img src="http://files.timber.io/images/readme-log-truth.png" height="947" /></a>
365
342
  </p>
@@ -13,17 +13,19 @@ module Timber
13
13
  class User < Context
14
14
  @keyspace = :user
15
15
 
16
- attr_reader :id, :name, :email
16
+ attr_reader :id, :name, :email, :type, :meta
17
17
 
18
18
  def initialize(attributes)
19
19
  @id = attributes[:id]
20
20
  @name = attributes[:name]
21
21
  @email = attributes[:email]
22
+ @type = attributes[:type]
23
+ @meta = attributes[:meta]
22
24
  end
23
25
 
24
26
  # Builds a hash representation containing simple objects, suitable for serialization (JSON).
25
27
  def as_json(_options = {})
26
- {id: Timber::Util::Object.try(id, :to_s), name: name, email: email}
28
+ {id: Timber::Util::Object.try(id, :to_s), name: name, email: email, type: type, meta: meta}
27
29
  end
28
30
  end
29
31
  end
@@ -9,7 +9,7 @@ module Timber
9
9
  class LogEntry #:nodoc:
10
10
  DT_PRECISION = 6.freeze
11
11
  MESSAGE_MAX_BYTES = 8192.freeze
12
- SCHEMA = "https://raw.githubusercontent.com/timberio/log-event-json-schema/v3.0.7/schema.json".freeze
12
+ SCHEMA = "https://raw.githubusercontent.com/timberio/log-event-json-schema/v3.1.1/schema.json".freeze
13
13
 
14
14
  attr_reader :context_snapshot, :event, :level, :message, :progname, :tags, :time, :time_ms
15
15
 
@@ -1,3 +1,3 @@
1
1
  module Timber
2
- VERSION = "2.1.3"
2
+ VERSION = "2.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timber
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
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: 2017-08-14 00:00:00.000000000 Z
11
+ date: 2017-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack