Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
binarylogic committed Feb 19, 2017
1 parent b2a2640 commit 2add2b2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Timber will *never* deviate from the public `::Logger` interface in *any* way.

</p></details>

<details><summary><strong>Tagging</strong></summary><p>
<details><summary><strong>Tagging logs</strong></summary><p>

Need a quick way to identify logs? Use tags!:

Expand Down Expand Up @@ -156,13 +156,16 @@ end
# My log message @metadata {"level": "info", "tags": ["tag"], "context": {...}}
```

* In the Timber console use the query: `tags:tag`.

---

</p></details>

<details><summary><strong>Timings & Durations</strong></summary><p>
<details><summary><strong>Timings, Durations, & Metrics</strong></summary><p>

Sometimes you need a quick way to add timings to log statements:
Timings allow you to easily capture one-off timings in your code; a simple
way to benchmark code execution:

```ruby
start = Time.now
Expand All @@ -173,7 +176,9 @@ logger.info(message: "Task complete", time_ms: time_ms)
# My log message @metadata {"level": "info", "time_ms": 54.2132, "context": {...}}
```

* The `:time_ms` attribute is supported by Timber. If present, we will display it in the interface, etc.
* In the Timber console use the query: `time_ms>500`
* The Timber console will also display this value inline with your logs. No need to include it
in the log message, but you certainly can if you'd prefer.

---

Expand All @@ -182,6 +187,10 @@ logger.info(message: "Task complete", time_ms: time_ms)

<details><summary><strong>Custom events</strong></summary><p>

Custom events can be used to structure information about events that are central
to your line of business like receiving credit card payments, saving a draft of a post,
or changing a user's password. You have 2 options to do this:

1. Log a structured Hash (simplest)

```ruby
Expand All @@ -208,7 +217,7 @@ logger.info(message: "Task complete", time_ms: time_ms)
# Payment rejected @metadata {"level": "warn", "event": {"payment_rejected": {"customer_id": "abcd1234", "amount": 100, "reason": "Card expired"}}, "context": {...}}
```

* `:type` is how Timber classifies the event, it creates a namespace for the data you send.
* In the Timber console use queries like: `payment_rejected.customer_id:xiaus1934` or `payment_rejected.amount>100`
* For more advanced examples see [`Timber::Logger`](lib/timber.logger.rb).
* Also, notice there is no mention of Timber in the above code. Just plain old logging.

Expand Down

0 comments on commit 2add2b2

Please sign in to comment.