Class: TreasureData::Logger::RailsAgent::ControllerLogger::ActionLogger
- Inherits:
-
Object
- Object
- TreasureData::Logger::RailsAgent::ControllerLogger::ActionLogger
- Defined in:
- lib/td/logger.rb
Constant Summary collapse
- PARAM_KEY =
if defined? Rails if Rails.respond_to?(:version) && Rails.version =~ /^3/ # Rails 3 'action_dispatch.request.path_parameters' else # Rails 2 'action_controller.request.path_parameters' end else # Rack default 'rack.routing_args' end
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(method, tag, options) ⇒ ActionLogger
constructor
A new instance of ActionLogger.
Constructor Details
#initialize(method, tag, options) ⇒ ActionLogger
Returns a new instance of ActionLogger.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/td/logger.rb', line 157 def initialize(method, tag, ) @method = method @tag = tag @only = nil @except = nil @extra = nil @static = {} if o = [:only_params] @only = case o when Array o else [o] end.map {|e| e.to_s } end if o = [:except_params] @except = case o when Array o else [o] end.map {|e| e.to_s } end if o = [:extra] @extra = case o when Hash m = {} o.each_pair {|k,v| m[k.to_s] = v.to_s } m when Array o.map {|e| case e when Hash m = {} e.each_pair {|k,v| m[k.to_s] = v.to_s } m else {e.to_s => e.to_s} end }.inject({}) {|r,e| r.merge!(e) } else {o.to_s => o.to_s} end end if o = [:static] o.each_pair {|k,v| @static[k] = v } end end |
Instance Method Details
#call(env) ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/td/logger.rb', line 211 def call(env) m = env[PARAM_KEY].dup || {} if @only m.reject! {|k,v| !@only.include?(k) } end if @except m.reject! {|k,v| @except.include?(k) } end if @extra @extra.each_pair {|k,v| m[v] = env[k] } end m.merge!(@static) ::TreasureData.log(@tag, m) end |