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

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
binarylogic committed Feb 23, 2017
1 parent cbfbd91 commit 7f7e574
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/timber/contexts/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@ module Contexts
# Note: Timber will attempt to automatically add this if you add a #current_user
# method to your controllers. Most authentication solutions do this for you automatically.
#
# Example:
#
# @example Basic example
# user_context = Timber::Contexts::User.new(id: "abc1234", name: "Ben Johnson")
# Timber::CurrentContext.with(user_context) do
# # Logging will automatically include this context
# logger.info("This is a log message")
# end
#
# @example Rails example
# class ApplicationController < ActionController::Base
# around_filter :capture_user_context
# private
# def capture_user_context
# if current_user
# user_context = Timber::Contexts::User.new(id: current_user.id,
# name: current_user.name, email: current_user.email)
# Timber::CurrentContext.with(user_context) { yield }
# else
# yield
# end
# end
# end
class User < Context
@keyspace = :user

Expand Down

0 comments on commit 7f7e574

Please sign in to comment.