timber 2.6.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +8 -38
  3. data/CHANGELOG.md +9 -0
  4. data/README.md +30 -284
  5. data/Rakefile +78 -0
  6. data/lib/timber.rb +6 -6
  7. data/lib/timber/config.rb +1 -83
  8. data/lib/timber/config/integrations.rb +1 -47
  9. data/lib/timber/context.rb +3 -24
  10. data/lib/timber/contexts.rb +2 -30
  11. data/lib/timber/contexts/http.rb +16 -36
  12. data/lib/timber/contexts/release.rb +12 -23
  13. data/lib/timber/contexts/runtime.rb +9 -36
  14. data/lib/timber/contexts/session.rb +8 -21
  15. data/lib/timber/contexts/system.rb +9 -16
  16. data/lib/timber/contexts/user.rb +13 -33
  17. data/lib/timber/current_context.rb +16 -78
  18. data/lib/timber/event.rb +12 -9
  19. data/lib/timber/events.rb +1 -33
  20. data/lib/timber/events/controller_call.rb +20 -31
  21. data/lib/timber/events/error.rb +18 -26
  22. data/lib/timber/events/exception.rb +1 -0
  23. data/lib/timber/events/sql_query.rb +14 -24
  24. data/lib/timber/events/template_render.rb +13 -24
  25. data/lib/timber/integration.rb +1 -1
  26. data/lib/timber/integrator.rb +1 -1
  27. data/lib/timber/log_devices/http.rb +98 -19
  28. data/lib/timber/log_entry.rb +6 -24
  29. data/lib/timber/logger.rb +5 -14
  30. data/lib/timber/util.rb +1 -6
  31. data/lib/timber/util/non_nil_hash_builder.rb +3 -1
  32. data/lib/timber/version.rb +1 -1
  33. data/spec/README.md +2 -8
  34. data/spec/spec_helper.rb +0 -7
  35. data/spec/support/timber.rb +1 -3
  36. data/spec/timber/current_context_spec.rb +12 -50
  37. data/spec/timber/events/controller_call_spec.rb +4 -4
  38. data/spec/timber/events/error_spec.rb +4 -9
  39. data/spec/timber/log_devices/http_spec.rb +26 -2
  40. data/spec/timber/log_entry_spec.rb +12 -6
  41. data/spec/timber/logger_spec.rb +27 -68
  42. data/timber.gemspec +1 -1
  43. metadata +5 -139
  44. data/gemfiles/rails-3.0.gemfile +0 -5
  45. data/gemfiles/rails-3.1.gemfile +0 -5
  46. data/gemfiles/rails-3.2.gemfile +0 -5
  47. data/gemfiles/rails-4.0.gemfile +0 -9
  48. data/gemfiles/rails-4.1.gemfile +0 -9
  49. data/gemfiles/rails-4.2.gemfile +0 -9
  50. data/gemfiles/rails-5.0.gemfile +0 -9
  51. data/gemfiles/rails-5.1.gemfile +0 -9
  52. data/gemfiles/rails-edge.gemfile +0 -7
  53. data/lib/timber/cli.rb +0 -60
  54. data/lib/timber/cli/api.rb +0 -183
  55. data/lib/timber/cli/api/application.rb +0 -34
  56. data/lib/timber/cli/config_file.rb +0 -71
  57. data/lib/timber/cli/file_helper.rb +0 -53
  58. data/lib/timber/cli/installer.rb +0 -70
  59. data/lib/timber/cli/installers.rb +0 -102
  60. data/lib/timber/cli/installers/config_file.rb +0 -51
  61. data/lib/timber/cli/installers/other.rb +0 -59
  62. data/lib/timber/cli/installers/rails.rb +0 -225
  63. data/lib/timber/cli/installers/root.rb +0 -116
  64. data/lib/timber/cli/io.rb +0 -100
  65. data/lib/timber/cli/io/ansi.rb +0 -22
  66. data/lib/timber/cli/io/messages.rb +0 -198
  67. data/lib/timber/cli/os_helper.rb +0 -74
  68. data/lib/timber/config/integrations/rack.rb +0 -74
  69. data/lib/timber/contexts/custom.rb +0 -44
  70. data/lib/timber/contexts/organization.rb +0 -48
  71. data/lib/timber/events/custom.rb +0 -53
  72. data/lib/timber/events/http_request.rb +0 -71
  73. data/lib/timber/events/http_response.rb +0 -81
  74. data/lib/timber/frameworks.rb +0 -19
  75. data/lib/timber/frameworks/rails.rb +0 -27
  76. data/lib/timber/integrations.rb +0 -29
  77. data/lib/timber/integrations/action_controller.rb +0 -18
  78. data/lib/timber/integrations/action_controller/log_subscriber.rb +0 -27
  79. data/lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb +0 -46
  80. data/lib/timber/integrations/action_dispatch.rb +0 -23
  81. data/lib/timber/integrations/action_dispatch/debug_exceptions.rb +0 -53
  82. data/lib/timber/integrations/action_view.rb +0 -18
  83. data/lib/timber/integrations/action_view/log_subscriber.rb +0 -27
  84. data/lib/timber/integrations/action_view/log_subscriber/timber_log_subscriber.rb +0 -83
  85. data/lib/timber/integrations/active_record.rb +0 -18
  86. data/lib/timber/integrations/active_record/log_subscriber.rb +0 -26
  87. data/lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb +0 -53
  88. data/lib/timber/integrations/rack.rb +0 -27
  89. data/lib/timber/integrations/rack/error_event.rb +0 -64
  90. data/lib/timber/integrations/rack/http_context.rb +0 -27
  91. data/lib/timber/integrations/rack/http_events.rb +0 -210
  92. data/lib/timber/integrations/rack/middleware.rb +0 -28
  93. data/lib/timber/integrations/rack/session_context.rb +0 -65
  94. data/lib/timber/integrations/rack/user_context.rb +0 -135
  95. data/lib/timber/integrations/rails.rb +0 -22
  96. data/lib/timber/integrations/rails/rack_logger.rb +0 -60
  97. data/lib/timber/overrides.rb +0 -12
  98. data/lib/timber/overrides/active_support_3_tagged_logging.rb +0 -111
  99. data/lib/timber/overrides/active_support_buffered_logger.rb +0 -22
  100. data/lib/timber/overrides/active_support_tagged_logging.rb +0 -66
  101. data/lib/timber/overrides/lograge.rb +0 -18
  102. data/lib/timber/overrides/rails_stdout_logging.rb +0 -21
  103. data/lib/timber/util/active_support_log_subscriber.rb +0 -37
  104. data/lib/timber/util/attribute_normalizer.rb +0 -89
  105. data/lib/timber/util/hash.rb +0 -90
  106. data/lib/timber/util/request.rb +0 -72
  107. data/lib/timber/util/struct.rb +0 -16
  108. data/spec/rails/tagged_logging_spec.rb +0 -44
  109. data/spec/support/action_controller.rb +0 -8
  110. data/spec/support/active_record.rb +0 -32
  111. data/spec/support/rails.rb +0 -67
  112. data/spec/support/rails/templates/_partial.html +0 -1
  113. data/spec/support/rails/templates/template.html +0 -1
  114. data/spec/timber/cli/config_file_spec.rb +0 -26
  115. data/spec/timber/cli/installers/config_file_spec.rb +0 -36
  116. data/spec/timber/cli/installers/other_spec.rb +0 -49
  117. data/spec/timber/cli/installers/rails_spec.rb +0 -364
  118. data/spec/timber/cli/installers/root_spec.rb +0 -73
  119. data/spec/timber/config_spec.rb +0 -28
  120. data/spec/timber/contexts/custom_spec.rb +0 -11
  121. data/spec/timber/contexts/organization_spec.rb +0 -11
  122. data/spec/timber/contexts/runtime_spec.rb +0 -11
  123. data/spec/timber/contexts/system_spec.rb +0 -11
  124. data/spec/timber/contexts/user_spec.rb +0 -11
  125. data/spec/timber/contexts_spec.rb +0 -49
  126. data/spec/timber/event_spec.rb +0 -10
  127. data/spec/timber/events/custom_spec.rb +0 -36
  128. data/spec/timber/events/http_request_spec.rb +0 -32
  129. data/spec/timber/events/http_response_spec.rb +0 -12
  130. data/spec/timber/events_spec.rb +0 -55
  131. data/spec/timber/integrations/action_controller/log_subscriber_spec.rb +0 -55
  132. data/spec/timber/integrations/action_dispatch/debug_exceptions_spec.rb +0 -53
  133. data/spec/timber/integrations/action_view/log_subscriber_spec.rb +0 -115
  134. data/spec/timber/integrations/active_record/log_subscriber_spec.rb +0 -46
  135. data/spec/timber/integrations/rack/error_event_spec.rb +0 -63
  136. data/spec/timber/integrations/rack/http_context_spec.rb +0 -60
  137. data/spec/timber/integrations/rack/http_events_spec.rb +0 -101
  138. data/spec/timber/integrations/rack/session_context_spec.rb +0 -62
  139. data/spec/timber/integrations/rails/rack_logger_spec.rb +0 -58
  140. data/spec/timber/util/attribute_normalizer_spec.rb +0 -90
  141. data/spec/timber/util/hash_spec.rb +0 -30
  142. data/spec/timber/util/request_spec.rb +0 -10
@@ -3,35 +3,22 @@ require "timber/util"
3
3
 
4
4
  module Timber
5
5
  module Contexts
6
- # The session context adds the current session ID to your logs. This allows you
7
- # to tail and filter logs by specific session IDs. Moreover, it gives you a unique
8
- # identifier to report on user activity by session. This way your logs can tell the
9
- # story of how many time a user has engaged your site.
10
- #
11
- # @note This is tracked automatically with the {Integrations::Rack::SessionContext} rack
12
- # middleware.
6
+ # @private
13
7
  class Session < Context
14
- ID_MAX_BYTES = 256.freeze
15
-
16
- @keyspace = :session
17
-
18
8
  attr_reader :id
19
9
 
20
10
  def initialize(attributes)
21
- normalizer = Util::AttributeNormalizer.new(attributes)
22
- @id = normalizer.fetch!(:id, :string, :limit => ID_MAX_BYTES)
11
+ @id = attributes[:id]
23
12
  end
24
13
 
25
14
  # Builds a hash representation containing simple objects, suitable for serialization (JSON).
26
15
  def to_hash
27
- @to_hash ||= Util::NonNilHashBuilder.build do |h|
28
- h.add(:id, id)
29
- end
30
- end
31
-
32
- def as_json(_options = {})
33
- to_hash
16
+ @to_hash ||= {
17
+ session: Util::NonNilHashBuilder.build do |h|
18
+ h.add(:id, id)
19
+ end
20
+ }
34
21
  end
35
22
  end
36
23
  end
37
- end
24
+ end
@@ -8,29 +8,22 @@ module Timber
8
8
  # @note This is tracked automatically in {CurrentContext}. When the current context
9
9
  # is initialized, the system context gets added automatically.
10
10
  class System < Context
11
- HOSTNAME_MAX_BYTES = 256.freeze
12
-
13
- @keyspace = :system
14
-
15
11
  attr_reader :hostname, :pid
16
12
 
17
13
  def initialize(attributes)
18
- normalizer = Util::AttributeNormalizer.new(attributes)
19
- @hostname = normalizer.fetch(:hostname, :string, :limit => HOSTNAME_MAX_BYTES)
20
- @pid = normalizer.fetch(:pid, :integer)
14
+ @hostname = attributes[:hostname]
15
+ @pid = attributes[:pid]
21
16
  end
22
17
 
23
18
  # Builds a hash representation containing simple objects, suitable for serialization (JSON).
24
19
  def to_hash
25
- @to_hash ||= Util::NonNilHashBuilder.build do |h|
26
- h.add(:hostname, hostname)
27
- h.add(:pid, pid)
28
- end
29
- end
30
-
31
- def as_json(_options = {})
32
- to_hash
20
+ @to_hash ||= {
21
+ system: Util::NonNilHashBuilder.build do |h|
22
+ h.add(:hostname, hostname)
23
+ h.add(:pid, pid)
24
+ end
25
+ }
33
26
  end
34
27
  end
35
28
  end
36
- end
29
+ end
@@ -3,46 +3,26 @@ require "timber/util"
3
3
 
4
4
  module Timber
5
5
  module Contexts
6
- # The user context adds data about the currently authenticated user to your logs.
7
- # By adding this context all of your logs will contain user information. This allows
8
- # filter and tail logs by specific users.
9
- #
10
- # @note This is tracked automatically with the {Integrations::Rack::UserContext} rack
11
- # middleware for supported authentication frameworks. See {Integrations::Rack::UserContext}
12
- # for more details.
6
+ # @private
13
7
  class User < Context
14
- ID_MAX_BYTES = 256.freeze
15
- NAME_MAX_BYTES = 256.freeze
16
- EMAIL_MAX_BYTES = 256.freeze
17
- TYPE_MAX_BYTES = 256.freeze
18
-
19
- @keyspace = :user
20
-
21
- attr_reader :id, :name, :email, :type, :meta
8
+ attr_reader :id, :name, :email
22
9
 
23
10
  def initialize(attributes)
24
- normalizer = Util::AttributeNormalizer.new(attributes)
25
- @id = normalizer.fetch(:id, :string, :limit => ID_MAX_BYTES)
26
- @name = normalizer.fetch(:name, :string, :limit => NAME_MAX_BYTES)
27
- @email = normalizer.fetch(:email, :string, :limit => EMAIL_MAX_BYTES)
28
- @type = normalizer.fetch(:type, :string, :limit => TYPE_MAX_BYTES)
29
- @meta = normalizer.fetch(:meta, :hash)
11
+ @id = attributes[:id]
12
+ @name = attributes[:name]
13
+ @email = attributes[:email]
30
14
  end
31
15
 
32
16
  # Builds a hash representation containing simple objects, suitable for serialization (JSON).
33
17
  def to_hash
34
- @to_hash ||= Util::NonNilHashBuilder.build do |h|
35
- h.add(:id, id)
36
- h.add(:name, name)
37
- h.add(:email, email)
38
- h.add(:type, type)
39
- h.add(:meta, meta)
40
- end
41
- end
42
-
43
- def as_json(_options = {})
44
- to_hash
18
+ @to_hash ||= {
19
+ user: Util::NonNilHashBuilder.build do |h|
20
+ h.add(:id, id)
21
+ h.add(:name, name)
22
+ h.add(:email, email)
23
+ end
24
+ }
45
25
  end
46
26
  end
47
27
  end
48
- end
28
+ end
@@ -1,8 +1,6 @@
1
1
  require "socket"
2
2
 
3
3
  require "timber/config"
4
- require "timber/contexts/release"
5
- require "timber/contexts/system"
6
4
 
7
5
  module Timber
8
6
  # Holds the current context in a thread safe memory storage. This context is
@@ -21,11 +19,6 @@ module Timber
21
19
  Thread.current[THREAD_NAMESPACE] ||= new
22
20
  end
23
21
 
24
- # Convenience method for {CurrentContext#with}. See {CurrentContext#with} for more info.
25
- def with(*args, &block)
26
- instance.with(*args, &block)
27
- end
28
-
29
22
  # Convenience method for {CurrentContext#add}. See {CurrentContext#add} for more info.
30
23
  def add(*args)
31
24
  instance.add(*args)
@@ -47,32 +40,6 @@ module Timber
47
40
  end
48
41
  end
49
42
 
50
- # Adds a context and then removes it when the block is finished executing.
51
- #
52
- # @note Because context is included with every log line, it is recommended that you limit this
53
- # to only neccessary data.
54
- #
55
- # @example Adding a custom context
56
- # Timber::CurrentContext.with({build: {version: "1.0.0"}}) do
57
- # # ... anything logged here will include the context ...
58
- # end
59
- #
60
- # @note Any custom context needs to have a single root key to be valid. i.e. instead of:
61
- # Timber::CurrentContext.with(job_id: "123", job_name: "Refresh User Account")
62
- #
63
- # do
64
- #
65
- # Timber::CurrentContext.with(job: {job_id: "123", job_name: "Refresh User Account"})
66
- #
67
- # @example Adding multiple contexts
68
- # Timber::CurrentContext.with(context1, context2) { ... }
69
- def with(*objects)
70
- add(*objects)
71
- yield
72
- ensure
73
- remove(*objects)
74
- end
75
-
76
43
  # Adds contexts but does not remove them. See {#with} for automatic maintenance and {#remove}
77
44
  # to remove them yourself.
78
45
  #
@@ -80,7 +47,7 @@ module Timber
80
47
  # to only neccessary data.
81
48
  def add(*objects)
82
49
  objects.each do |object|
83
- add_to!(hash, object)
50
+ hash.merge!(object.to_hash)
84
51
  end
85
52
  expire_cache!
86
53
  self
@@ -93,23 +60,9 @@ module Timber
93
60
 
94
61
  # Removes a context. If you wish to remove by key, or some other way, use {#hash} and
95
62
  # modify the hash accordingly.
96
- def remove(*objects)
97
- objects.each do |object|
98
- if object.is_a?(Symbol)
99
- hash.delete(object)
100
- else
101
- context = Contexts.build(object)
102
-
103
- if context.keyspace == :custom
104
- # Custom contexts are merged and should be removed the same
105
- hash[context.keyspace].delete(context.type)
106
- if hash[context.keyspace] == {}
107
- hash.delete(context.keyspace)
108
- end
109
- else
110
- hash.delete(context.keyspace)
111
- end
112
- end
63
+ def remove(*keys)
64
+ keys.each do |keys|
65
+ hash.delete(keys)
113
66
  end
114
67
  expire_cache!
115
68
  self
@@ -127,13 +80,7 @@ module Timber
127
80
  # since the context can change as execution proceeds. Note that individual contexts
128
81
  # should be immutable, and we implement snapshot caching as a result of this assumption.
129
82
  def snapshot
130
- @snapshot ||= begin
131
- snapshot = hash.clone
132
- if snapshot.key?(:custom)
133
- snapshot[:custom] = hash[:custom].clone
134
- end
135
- snapshot
136
- end
83
+ @snapshot ||= hash.clone
137
84
  end
138
85
 
139
86
  private
@@ -149,39 +96,30 @@ module Timber
149
96
  new_hash = {}
150
97
 
151
98
  # Release context
152
- release_context = Contexts::Release.from_env
153
- if release_context
154
- add_to!(new_hash, release_context)
99
+ release_context = Util::NonNilHashBuilder.build do |h|
100
+ h.add(:commit_hash, ENV['RELEASE_COMMIT'] || ENV['HEROKU_SLUG_COMMIT'])
101
+ h.add(:created_at, ENV['RELEASE_CREATED_AT'] || ENV['HEROKU_RELEASE_CREATED_AT'])
102
+ h.add(:version, ENV['RELEASE_VERSION'] || ENV['HEROKU_RELEASE_VERSION'])
103
+ end
104
+
105
+ if release_context != {}
106
+ new_hash.merge!({release: release_context})
155
107
  end
156
108
 
157
109
  # System context
158
110
  hostname = Socket.gethostname
159
111
  pid = Process.pid
160
112
  system_context = Contexts::System.new(hostname: hostname, pid: pid)
161
- add_to!(new_hash, system_context)
113
+ new_hash.merge!(system_context.to_hash)
162
114
 
163
115
  # Runtime context
164
116
  thread_object_id = Thread.current.object_id
165
- runtime_context = Contexts::Runtime.new(vm_pid: thread_object_id)
166
- add_to!(new_hash, runtime_context)
117
+ runtime_context = {thread_id: thread_object_id}
118
+ new_hash.merge!({runtime: runtime_context})
167
119
 
168
120
  new_hash
169
121
  end
170
122
 
171
- def add_to!(hash, object)
172
- context = Contexts.build(object) # Normalizes objects into a Timber::Context descendant.
173
- key = context.keyspace
174
- json = context.as_json # Convert to json now so that we aren't doing it for every line
175
- if key == :custom
176
- # Custom contexts are merged into the space
177
- hash[key] ||= {}
178
- hash[key].merge!(json)
179
- else
180
- hash[key] = json
181
- end
182
- hash
183
- end
184
-
185
123
  # Hook to clear any caching implement in this class
186
124
  def expire_cache!
187
125
  @snapshot = nil
@@ -2,12 +2,10 @@ module Timber
2
2
  # Base class for `Timber::Events::*`
3
3
  # @private
4
4
  class Event
5
- def message
6
- raise NotImplementedError.new
7
- end
8
-
9
- def as_json(options = {})
10
- raise NotImplementedError.new
5
+ attr_reader :message, :metadata
6
+ def initialize(message, metadata)
7
+ @message = message || ""
8
+ @metadata = metadata || {}
11
9
  end
12
10
 
13
11
  # This ensures that Timber events get logged as messages if they are passed to
@@ -19,15 +17,20 @@ module Timber
19
17
  end
20
18
 
21
19
  def to_json(options = {})
22
- as_json.to_json(options)
20
+ metadata.to_json(options)
21
+ end
22
+
23
+ def to_hash
24
+ metadata
23
25
  end
26
+ alias to_h to_hash
24
27
 
25
28
  def to_msgpack(*args)
26
- as_json.to_msgpack(*args)
29
+ metadata.to_msgpack(*args)
27
30
  end
28
31
 
29
32
  def to_s
30
33
  message
31
34
  end
32
35
  end
33
- end
36
+ end
@@ -1,42 +1,10 @@
1
1
  require "timber/events/controller_call"
2
- require "timber/events/custom"
3
2
  require "timber/events/error"
4
- require "timber/events/http_request"
5
- require "timber/events/http_response"
6
3
  require "timber/events/sql_query"
7
4
  require "timber/events/template_render"
8
5
 
9
6
  module Timber
10
7
  # Namespace for all Timber supported events.
11
8
  module Events
12
- # Protocol for casting objects into a `Timber::Event`.
13
- #
14
- # @example Casting a hash
15
- # Timber::Events.build({type: :custom_event, message: "My log message", data: {my: "data"}})
16
- def self.build(obj)
17
- if obj.is_a?(::Timber::Event)
18
- obj
19
- elsif obj.respond_to?(:to_timber_event)
20
- obj.to_timber_event
21
- elsif obj.is_a?(Hash) && obj.key?(:message) && obj.length == 2
22
- event = obj.select { |k,v| k != :message }
23
- type = event.keys.first
24
- data = event.values.first
25
-
26
- Events::Custom.new(
27
- type: type,
28
- message: obj[:message],
29
- data: data
30
- )
31
- elsif obj.is_a?(Struct) && obj.respond_to?(:message) && obj.respond_to?(:type)
32
- Events::Custom.new(
33
- type: obj.type,
34
- message: obj.message,
35
- data: obj.respond_to?(:to_h) ? obj.to_h : Timber::Util::Struct.to_hash(obj) # ruby 1.9.3 does not have to_h :(
36
- )
37
- else
38
- nil
39
- end
40
- end
41
9
  end
42
- end
10
+ end
@@ -1,43 +1,22 @@
1
- require "timber/event"
2
1
  require "timber/util"
2
+ require "timber/event"
3
3
 
4
4
  module Timber
5
5
  module Events
6
- # The controller call event tracks controller invocations. For example, this line in Rails:
7
- #
8
- # Processing by PagesController#home as HTML
9
- #
10
- # @note This event should be installed automatically through integrations,
11
- # such as the {Integrations::ActionController} integration.
6
+ # @private
12
7
  class ControllerCall < Timber::Event
13
- ACTION_MAX_BYTES = 256.freeze
14
- FORMAT_MAX_BYTES = 256.freeze
15
- CONTROLLER_MAX_BYTES = 256.freeze
16
- PARAMS_JSON_MAX_BYTES = 32_768.freeze
17
- PASSWORD_NAME = 'password'.freeze
18
-
19
- attr_reader :controller, :action, :params, :format
8
+ attr_reader :controller, :action, :params, :params_json, :format
20
9
 
21
10
  def initialize(attributes)
22
- normalizer = Util::AttributeNormalizer.new(attributes)
23
- @controller = normalizer.fetch!(:controller, :string, :limit => CONTROLLER_MAX_BYTES)
24
- @action = normalizer.fetch!(:action, :string, :limit => ACTION_MAX_BYTES)
25
- @params = normalizer.fetch(:params, :hash, :sanitize => [PASSWORD_NAME])
26
- @format = normalizer.fetch(:format, :string, :limit => FORMAT_MAX_BYTES)
27
- end
11
+ @controller = attributes[:controller]
12
+ @action = attributes[:action]
13
+ @params = attributes[:params]
28
14
 
29
- def to_hash
30
- @to_hash ||= Util::NonNilHashBuilder.build do |h|
31
- h.add(:controller, controller)
32
- h.add(:action, action)
33
- h.add(:params_json, params.to_json.byteslice(0, PARAMS_JSON_MAX_BYTES))
15
+ if @params
16
+ @params_json = @params.to_json
34
17
  end
35
- end
36
- alias to_h to_hash
37
18
 
38
- # Builds a hash representation containing simple objects, suitable for serialization (JSON).
39
- def as_json(_options = {})
40
- {:controller_call => to_hash}
19
+ @format = attributes[:format]
41
20
  end
42
21
 
43
22
  def message
@@ -50,6 +29,16 @@ module Timber
50
29
  end
51
30
  message
52
31
  end
32
+
33
+ def to_hash
34
+ {
35
+ controller_called: Util::NonNilHashBuilder.build do |h|
36
+ h.add(:controller, controller)
37
+ h.add(:action, action)
38
+ h.add(:params_json, params_json)
39
+ end
40
+ }
41
+ end
53
42
  end
54
43
  end
55
- end
44
+ end