timber 2.1.5 → 2.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -29
- data/lib/timber.rb +15 -0
- data/lib/timber/logger.rb +1 -2
- data/lib/timber/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baa611c5defcf24154ffcb829af28252a93b7eda
|
4
|
+
data.tar.gz: 08ecbf18b034d297b1d184c362bb6789b7655df6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aec84b46f8264c4ea92413c5c85c3277751691148048bb98a8f13554473301429b783c04c1fe5037e13985f3489042fe682dde07064fb59f5601c6cce8a828b6
|
7
|
+
data.tar.gz: 716a20f56eec22a0447d2a7752b21e5a5de98d887991325ff0a7dad3253ef4cfba89d13ca36f48f9f09153d06d8f37635c0eb18d136739d117fdc745f876cd56
|
data/README.md
CHANGED
@@ -4,17 +4,15 @@
|
|
4
4
|
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/timberio/timber-ruby)
|
5
5
|
[![Build Status](https://travis-ci.org/timberio/timber-ruby.svg?branch=master)](https://travis-ci.org/timberio/timber-ruby)
|
6
6
|
|
7
|
-
[Timber
|
8
|
-
This
|
7
|
+
[Timber](https://timber.io) is a cloud-based logging system that integrates directly with your
|
8
|
+
Ruby app to capture context and metadata without parsing. This produces rich, clean, readable logs
|
9
|
+
that are easier to search and use:
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
2. [**Powerful logging**](#usage)
|
16
|
-
3. [**Seamlessly integrates with popular libraries and frameworks**](#integrations)
|
17
|
-
4. [**Do amazing things with your Ruby logs**](#do-amazing-things-with-your-logs)
|
11
|
+
1. [**Installation** - One command: `bundle exec timber install`](#installation)
|
12
|
+
2. [**Usage** - Simple yet powerful API](#usage)
|
13
|
+
3. [**Integrations** - Automatic context and metadata for your existing logs](#integrations)
|
14
|
+
4. [**The Timber Console** - Designed for Ruby developers](#the-timber-console)
|
15
|
+
5. [**Get things done with your logs 💪**](#get-things-done-with-your-logs)
|
18
16
|
|
19
17
|
|
20
18
|
## Installation
|
@@ -91,7 +89,7 @@ have to maually set these contexts except in special circumstances.
|
|
91
89
|
### How to use it
|
92
90
|
|
93
91
|
```ruby
|
94
|
-
|
92
|
+
Timber.with_context(job: {id: 123}) do
|
95
93
|
logger.info("Background job execution started")
|
96
94
|
# ... code here
|
97
95
|
logger.info("Background job execution completed")
|
@@ -120,7 +118,7 @@ you are unsure how you'll need to use your data in the future.
|
|
120
118
|
Below is a contrived example of timing a background job:
|
121
119
|
|
122
120
|
```ruby
|
123
|
-
timer = Timber
|
121
|
+
timer = Timber.start_timer
|
124
122
|
# ... code to time ...
|
125
123
|
logger.info("Processed background job", background_job: {time_ms: timer})
|
126
124
|
```
|
@@ -162,8 +160,7 @@ option for anyone transitioning from lograge.
|
|
162
160
|
```ruby
|
163
161
|
# config/initializers/timber.rb
|
164
162
|
|
165
|
-
|
166
|
-
config.logrageify!()
|
163
|
+
Timber.config.logrageify!()
|
167
164
|
```
|
168
165
|
|
169
166
|
### How it works
|
@@ -192,11 +189,10 @@ Internally this is equivalent to:
|
|
192
189
|
```ruby
|
193
190
|
# config/initializers/timber.rb
|
194
191
|
|
195
|
-
config =
|
196
|
-
config.integrations.
|
197
|
-
config.integrations.
|
198
|
-
config.integrations.
|
199
|
-
config.integrations.rack.http_events.collapse_into_single_event = true
|
192
|
+
Timber.config.integrations.action_controller.silence = true
|
193
|
+
Timber.config.integrations.action_view.silence = true
|
194
|
+
Timber.config.integrations.active_record.silence = true
|
195
|
+
Timber.config.integrations.rack.http_events.collapse_into_single_event = true
|
200
196
|
```
|
201
197
|
|
202
198
|
### Pro-tip: Keep controller call logs (recommended)
|
@@ -207,10 +203,9 @@ from lograge with the following settings:
|
|
207
203
|
```ruby
|
208
204
|
# config/initializers/timber.rb
|
209
205
|
|
210
|
-
config =
|
211
|
-
config.integrations.
|
212
|
-
config.integrations.
|
213
|
-
config.integrations.rack.http_events.collapse_into_single_event = true
|
206
|
+
Timber.config.integrations.action_view.silence = true
|
207
|
+
Timber.config.integrations.active_record.silence = true
|
208
|
+
Timber.config.integrations.rack.http_events.collapse_into_single_event = true
|
214
209
|
```
|
215
210
|
|
216
211
|
This does _not_ silence the controller call log event. This is because Timber captures the
|
@@ -235,8 +230,7 @@ The following will silence all `[GET] /_health` requests:
|
|
235
230
|
```ruby
|
236
231
|
# config/initializers/timber.rb
|
237
232
|
|
238
|
-
config =
|
239
|
-
config.integrations.rack.http_events.silence_request = lambda do |rack_env, rack_request|
|
233
|
+
Timber.config.integrations.rack.http_events.silence_request = lambda do |rack_env, rack_request|
|
240
234
|
rack_request.path == "/_health"
|
241
235
|
end
|
242
236
|
```
|
@@ -264,8 +258,7 @@ you can do so like:
|
|
264
258
|
```ruby
|
265
259
|
# config/initializers/timber.rb
|
266
260
|
|
267
|
-
config =
|
268
|
-
config.integrations.rack.user_context.custom_user_hash = lambda do |rack_env|
|
261
|
+
Timber.config.integrations.rack.user_context.custom_user_hash = lambda do |rack_env|
|
269
262
|
user = rack_env['warden'].user
|
270
263
|
if user
|
271
264
|
{
|
@@ -324,9 +317,9 @@ support:
|
|
324
317
|
8. ...more coming soon! Make a request by [opening an issue](https://github.com/timberio/timber-ruby/issues/new)
|
325
318
|
|
326
319
|
|
327
|
-
##
|
320
|
+
## Get things done with your logs
|
328
321
|
|
329
|
-
|
322
|
+
Logging features every developer needs:
|
330
323
|
|
331
324
|
1. [**Powerful searching.** - Find what you need faster.](https://timber.io/docs/app/console/searching)
|
332
325
|
2. [**Live tail users.** - Easily solve customer issues.](https://timber.io/docs/app/console/tail-a-user)
|
data/lib/timber.rb
CHANGED
@@ -18,4 +18,19 @@ require "timber/timer"
|
|
18
18
|
require "timber/frameworks"
|
19
19
|
|
20
20
|
module Timber
|
21
|
+
# Access the main configuration object. Please see {{Timber::Config}} for more details.
|
22
|
+
def self.config
|
23
|
+
Config.instance
|
24
|
+
end
|
25
|
+
|
26
|
+
# Starts a timer for timing events. Please see {{Timber::Timber.start}} for more details.
|
27
|
+
def self.start_timer
|
28
|
+
Timer.start
|
29
|
+
end
|
30
|
+
|
31
|
+
# Adds context to all logs written within the passed block. Please see
|
32
|
+
# {{Timber::CurrentContext.with}} for a more detailed description with examples.
|
33
|
+
def self.with_context(context, &block)
|
34
|
+
CurrentContext.with(context, &block)
|
35
|
+
end
|
21
36
|
end
|
data/lib/timber/logger.rb
CHANGED
@@ -214,8 +214,7 @@ module Timber
|
|
214
214
|
super
|
215
215
|
end
|
216
216
|
|
217
|
-
#
|
218
|
-
# a more detailed description and examples.
|
217
|
+
# @private
|
219
218
|
def with_context(context, &block)
|
220
219
|
Timber::CurrentContext.with(context, &block)
|
221
220
|
end
|
data/lib/timber/version.rb
CHANGED
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.
|
4
|
+
version: 2.1.6
|
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-
|
11
|
+
date: 2017-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|