Custom events allow you to extend beyond events already defined in the Timber.Events namespace:

Looking for metrics? Checkout the metrics doc.

Implementation

event_data = %{customer_id: "xiaus1934", amount: 1900, currency: "USD"}
Logger.info("Payment rejected", event: %{payment_rejected: event_data})

# => Payment rejected @metadata {"level": "warn", "event": {"payment_rejected": {"customer_id": "xiaus1934", "amount": 100, "reason": "Card expired"}}, "context": {...}}
  • Notice the :payment_rejected root key. Timber will classify this event as such.

What you can do

  1. Use this data for querying your logs. Ex: type:payment_rejected or payment_rejected.amount:>100.
  2. View this custom event when inspecting log lines:

    Event panels

    Or view it in the raw JSON payload:

    Event raw

Limits

  • There are no limits to the depth of fields you can nest. As long as the resulting field path is less than 128 characters.
  • There are no limits to the number of custom fields you can send. As long as the result payload size is less than 2mb.

Questions? Need help?

Chat with us, just click the talk button in the bottom right of this page.

Chat with us

Start a trial - 15 days free

Log better and solve problems faster, today. Less than 1 minutes to install.

Start a trial