Class: Timber::Contexts::User
- Inherits:
-
Timber::Context
- Object
- Timber::Context
- Timber::Contexts::User
- Defined in:
- lib/timber/contexts/user.rb
Overview
This is tracked automatically with the Integrations::Rack::UserContext rack middleware for supported authentication frameworks. See Integrations::Rack::UserContext for more details.
The user context adds data about the currently authenticated user to your logs. By adding this context all of your logs will contain user information. This allows filter and tail logs by specific users.
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#as_json(_options = {}) ⇒ Object
Builds a hash representation containing simple objects, suitable for serialization (JSON).
-
#initialize(attributes) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(attributes) ⇒ User
Returns a new instance of User.
18 19 20 21 22 23 24 |
# File 'lib/timber/contexts/user.rb', line 18 def initialize(attributes) @id = Timber::Util::Object.try(attributes[:id], :to_s) @name = attributes[:name] @email = attributes[:email] @type = attributes[:type] @meta = attributes[:meta] end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
16 17 18 |
# File 'lib/timber/contexts/user.rb', line 16 def email @email end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
16 17 18 |
# File 'lib/timber/contexts/user.rb', line 16 def id @id end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
16 17 18 |
# File 'lib/timber/contexts/user.rb', line 16 def @meta end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/timber/contexts/user.rb', line 16 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
16 17 18 |
# File 'lib/timber/contexts/user.rb', line 16 def type @type end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
Builds a hash representation containing simple objects, suitable for serialization (JSON).
27 28 29 |
# File 'lib/timber/contexts/user.rb', line 27 def as_json( = {}) {id: id, name: name, email: email, type: type, meta: } end |