55[ ![ Build Status] ( https://travis-ci.org/timberio/timber-ruby.svg?branch=master )] ( https://travis-ci.org/timberio/timber-ruby )
66[ ![ Code Climate] ( https://codeclimate.com/github/timberio/timber-ruby/badges/gpa.svg )] ( https://codeclimate.com/github/timberio/timber-ruby )
77
8- [ Timber] ( https://timber.io ) is a cloud-based logging system that integrates directly with your Ruby
9- app through this library, capturing context and metadata without parsing. This produces rich, clean,
10- readable logs that are easier to search and use:
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.
1114
12151 . [ ** Installation** - One command: ` bundle exec timber install ` ] ( #installation )
13- 2 . [ ** Usage** - Simple yet powerful API] ( #usage )
16+ 2 . [ ** Usage** - Simple & powerful API] ( #usage )
14173 . [ ** Integrations** - Automatic context and metadata for your existing logs] ( #integrations )
15- 4 . [ ** The Timber Console** - Designed for Ruby developers] ( #the-timber-console )
18+ 4 . [ ** The Timber Console** - Designed for applications & developers] ( #the-timber-console )
16195 . [ ** Get things done with your logs 💪** ] ( #get-things-done-with-your-logs )
1720
1821
@@ -24,9 +27,11 @@ readable logs that are easier to search and use:
2427 gem ' timber' , ' ~> 2.1'
2528 ```
2629
27- 2 . In your ` shell` , run ` bundle install `
30+ 2 . In your ` shell` , run:
2831
29- 3 . In your ` shell` , run ` bundle exec timber install`
32+ ```
33+ bundle install && bundle exec timber install
34+ ```
3035
3136
3237# # Usage
@@ -43,51 +48,37 @@ logger.error("Error message")
4348logger.fatal("Fatal message")
4449` ` `
4550
46- We encourage standard / traditional log messages for non- meaningful events. And because Timber
47- [augments](https: / /timber.io/ docs/ concepts/ structuring- through- augmentation) your logs with
48- metadata, you don' t have to worry about making every log structured!
51+ 1 . [Search it](https: / /timber.io/ docs/ app/ console/ searching) with queries like: ` error message`
52+ 2 . [Alert on it](https: / /timber.io/ docs/ app/ console/ alerts) with threshold based alerts
53+ 3 . [View this event' s metadata and context](https://timber.io/docs/app/console/view-metdata-and-context)
54+
55+ [...read more in our docs](https://timber.io/docs/languages/ruby/usage/basic-logging)
4956
5057---
5158
5259</p></details>
5360
5461<details><summary><strong>Logging events (structured data)</strong></summary><p>
5562
56- Logging events allows you to log structured data without sacrificing readability or worrying about
57- structured data name or type conflicts. Keep in mind, Timber defines common events in the
58- [`Timber::Events`](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Events) namespace,
59- which are automatically logged for you through our [integrations](#integrations). You should not
60- have to maually log events defined there except in special circumstances.
61-
62- ### How to use it
63+ Log structured data without sacrificing readability:
6364
6465```ruby
6566logger.warn "Payment rejected", payment_rejected: {customer_id: "abcd1234", amount: 100, reason: "Card expired"}
6667```
6768
68691. [Search it](https://timber.io/docs/app/console/searching) with queries like: `type:payment_rejected` or `payment_rejected.amount:>100`
69702. [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)
71714. [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)
72+
73+ ...[read more in our docs](https: / /timber.io/ docs/ languages/ ruby/ usage/ custom- events)
7374
7475---
7576
7677< / p >< / details>
7778
7879< details>< summary>< strong> Setting context< / strong>< / summary>< p >
7980
80- Context is amazingly powerful, think of it like join data for your logs. It represents the
81- environment when the log was written, allowing you to relate logs so you can easily segment them.
82- It ' s how Timber is able to accomplish features like
83- [tailing users](https://timber.io/docs/app/console/tail-a-user) and
84- [tracing HTTP requests](https://timber.io/docs/app/console/trace-http-requests).
85- Keep in mind, Timber defines common contexts in the
86- [`Timber::Contexts`](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Contexts) namespace,
87- which are automatically set for you through our [integrations](#integrations). You should not
88- have to maually set these contexts except in special circumstances.
89-
90- ### How to use it
81+ Add shared structured data across your logs:
9182
9283` ` ` ruby
9384Timber.with_context(job: {id: 123}) do
9990
100911 . [Search it](https: / /timber.io/ docs/ app/ console/ searching) with queries like: ` job.id:123`
101922 . [View this context when viewing a log' s metadata](https://timber.io/docs/app/console/view-metdata-and-context)
102- 3 . ...read more in our [docs](https: / /timber.io/ docs/ languages/ ruby/ usage/ custom- context)
93+
94+ ...[read more in our docs](https://timber.io/docs/languages/ruby/usage/custom-context)
10395
10496---
10597
10698</p></details>
10799
108- < details>< summary>< strong> Metrics & Timings < / strong>< / summary>< p >
100+ <details><summary><strong>Metrics, Timings, & Tracing </strong></summary><p>
109101
110- Aggregates destroy details, events tell stories. With Timber , logging metrics and timings is simply
111- [logging an event](https: / /timber.io/ docs/ languages/ ruby/ usage/ custom- events). Timber is based on
112- modern big- data principles and can aggregate inordinately large data sets in seconds. Logging
113- events (raw data as it exists), gives you the flexibility in the future to segment and aggregate
114- your data any way you see fit. This is superior to choosing specific paradigms before hand, when
115- you are unsure how you' ll need to use your data in the future.
116-
117- ### How to use it
118-
119- Below is a contrived example of timing a background job:
102+ Time code blocks:
120103
121104```ruby
122105timer = Timber.start_timer
123106# ... code to time ...
124107logger.info("Processed background job", background_job: {time_ms: timer})
125108```
126109
127- And of course, `time_ms` can also take a `Float` or `Fixnum`:
128-
129- ```ruby
130- logger.info("Processed background job", background_job: {time_ms: 45.6})
131- ```
132-
133- Lastly, metrics aren' t limited to timings. You can capture any metric you want:
110+ Log generic metrics:
134111
135112```ruby
136113logger.info("Credit card charged", credit_card_charge: {amount: 123.23})
@@ -139,8 +116,8 @@ logger.info("Credit card charged", credit_card_charge: {amount: 123.23})
1391161. [Search it](https://timber.io/docs/app/console/searching) with queries like: `background_job.time_ms:>500`
1401172. [Alert on it](https://timber.io/docs/app/console/alerts) with threshold based alerts
1411183. [View this log' s metadata in the console](https: / /timber.io/ docs/ app/ console/ view- metdata- and - context)
142- 4. ...read more in our [docs](https://timber.io/docs/languages/ruby/usage/metrics-and-timings)
143119
120+ ...[read more in our docs](https: / /timber.io/ docs/ languages/ ruby/ usage/ metrics- and - timings)
144121
145122< / p >< / details>
146123
@@ -152,20 +129,14 @@ Below are a few popular configuration options, for a comprehensive list, see
152129
153130< details>< summary>< strong> Logrageify . Silence noisy logs.< / strong>< / summary>< p >
154131
155- Timber allows you to silence noisy logs that aren' t of value to you, just like
156- [lograge](https: // github.com/ roidrage/ lograge). As such, we' ve provided a convenience configuration
157- option for anyone transitioning from lograge.
158-
159- ### How to use it
132+ Silence noisy logs that aren' t of value to you, just like
133+ [lograge](https://github.com/roidrage/lograge):
160134
161135```ruby
162136# config/initializers/timber.rb
163-
164137Timber.config.logrageify!()
165138```
166139
167- ### How it works
168-
169140It turns this:
170141
171142```
@@ -182,18 +153,7 @@ Completed 200 OK in 79ms (Views: 78.8ms | ActiveRecord: 0.0ms)
182153Into this:
183154
184155```
185- Get "/" sent 200 OK in 79ms @metadata {...}
186- ```
187-
188- Internally this is equivalent to:
189-
190- ```ruby
191- # config/initializers/timber.rb
192-
193- Timber.config.integrations.action_controller.silence = true
194- Timber.config.integrations.action_view.silence = true
195- Timber.config.integrations.active_record.silence = true
196- Timber.config.integrations.rack.http_events.collapse_into_single_event = true
156+ Get "/" sent 200 OK in 79ms
197157```
198158
199159### Pro-tip: Keep controller call logs (recommended)
@@ -222,11 +182,8 @@ For a full list of integration settings, see
222182<details><summary><strong>Silence specific requests (LB health checks, etc)</strong></summary><p>
223183
224184Silencing noisy requests can be helpful for silencing load balance health checks, bot scanning,
225- or activity that generally is not meaningful to you.
226-
227- ### How to use it
228-
229- The following will silence all `[GET] /_health` requests:
185+ or activity that generally is not meaningful to you. The following will silence all
186+ `[GET] /_health` requests:
230187
231188```ruby
232189# config/initializers/timber.rb
@@ -247,12 +204,10 @@ The first parameter being the traditional Rack env hash, the second being a
247204<details><summary><strong>Capture custom user context</strong></summary><p>
248205
249206By default Timber automatically captures user context for most of the popular authentication
250- libraries (Devise, Omniauth, and Clearance). See
207+ libraries (Devise, and Clearance). See
251208[Timber::Integrations::Rack::UserContext](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Integrations/Rack/UserContext)
252209for a complete list.
253210
254- ### How to use it
255-
256211In cases where you Timber doesn' t support your strategy, or you want to customize it further,
257212you can do so like:
258213
284239[Timber ::Contexts ::Release ](http: // www.rubydoc.info/ github/ timberio/ timber- ruby/ Timber / Contexts / Release )
285240tracks the current application release and version.
286241
287- # ## How to use it
288-
289242If you' re on Heroku, simply enable the
290243[dyno metadata](https://devcenter.heroku.com/articles/dyno-metadata) feature. If you are not,
291244set the following environment variables and this context will be added automatically:
@@ -304,7 +257,7 @@ All variables are optional, but at least one must be present.
304257## Integrations
305258
306259Timber integrates with popular frameworks and libraries to capture context and metadata you
307- couldn' t otherwise. This automatically upgrades logs produced by these libraries, making them
260+ couldn' t otherwise. This automatically augments logs produced by these libraries, making them
308261[easier to search and use](# do-amazing-things-with-your-logs). Below is a list of libraries we
309262support:
310263
@@ -313,7 +266,6 @@ support:
313266 * [** Rack ** ](https: / /timber.io/ docs/ languages/ ruby/ integrations/ rack)
314267 * [** Devise ** ](https: / /timber.io/ docs/ languages/ ruby/ integrations/ devise)
315268 * [** Clearance ** ](https: / /timber.io/ docs/ languages/ ruby/ integrations/ clearnace)
316- * [** Omniauth ** ](https: / /timber.io/ docs/ languages/ ruby/ integrations/ omniauth)
317269 * [** Warden ** ](https: / /timber.io/ docs/ languages/ ruby/ integrations/ devise)
318270* Platforms
319271 * [** Heroku ** ](https: / /timber.io/ docs/ languages/ ruby/ integrations/ heroku)
@@ -324,7 +276,7 @@ support:
324276
325277# # Get things done with your logs
326278
327- Logging features every developer needs :
279+ Logging features designed to help developers get more done :
328280
3292811 . [** Powerful searching.** - Find what you need faster.](https: / /timber.io/ docs/ app/ console/ searching)
3302822 . [** Live tail users.** - Easily solve customer issues.](https: / /timber.io/ docs/ app/ console/ tail- a- user)
0 commit comments