lib/timber/contexts/user.rb in timber-2.0.24 vs lib/timber/contexts/user.rb in timber-2.1.0.rc1
- old
+ new
@@ -1,11 +1,17 @@
+require "timber/context"
+require "timber/util"
+
module Timber
module Contexts
- # The user context tracks the currently authenticated user.
+ # 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.
#
# @note This is tracked automatically with the {Integrations::Rack::UserContext} rack
- # middleware.
+ # middleware for supported authentication frameworks. See {Integrations::Rack::UserContext}
+ # for more details.
class User < Context
@keyspace = :user
attr_reader :id, :name, :email
@@ -13,9 +19,10 @@
@id = attributes[:id]
@name = attributes[:name]
@email = attributes[:email]
end
+ # Builds a hash representation of containing simply objects, suitable for serialization.
def as_json(_options = {})
{id: Timber::Util::Object.try(id, :to_s), name: name, email: email}
end
end
end
\ No newline at end of file