Module: LogicalModel::SafeLog::ClassMethods
- Defined in:
- lib/logical_model/safe_log.rb
Instance Attribute Summary collapse
-
#log_path ⇒ Object
Returns the value of attribute log_path.
Instance Method Summary collapse
- #log_failed(response) ⇒ Object
- #log_ok(response) ⇒ Object
- #logger ⇒ Object
-
#mask_api_key(str) ⇒ String
Filters api_key.
Instance Attribute Details
#log_path ⇒ Object
Returns the value of attribute log_path.
23 24 25 |
# File 'lib/logical_model/safe_log.rb', line 23 def log_path @log_path end |
Instance Method Details
#log_failed(response) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/logical_model/safe_log.rb', line 34 def log_failed(response) begin = ActiveSupport::JSON.decode(response.body)["message"] rescue => e = "error" end msg = "LogicalModel Log: #{response.code} #{mask_api_key(response.effective_url)} in #{response.time}s FAILED: #{}" self.logger.warn(msg) self.logger.debug("LogicalModel Log RESPONSE: #{response.body}") end |
#log_ok(response) ⇒ Object
29 30 31 32 |
# File 'lib/logical_model/safe_log.rb', line 29 def log_ok(response) self.logger.info("LogicalModel Log: #{response.code} #{mask_api_key(response.effective_url)} in #{response.time}s") self.logger.debug("LogicalModel Log RESPONSE: #{response.body}") end |
#logger ⇒ Object
45 46 47 |
# File 'lib/logical_model/safe_log.rb', line 45 def logger Logger.new(self.log_path || "log/logical_model.log") end |
#mask_api_key(str) ⇒ String
Filters api_key
51 52 53 54 55 56 |
# File 'lib/logical_model/safe_log.rb', line 51 def mask_api_key(str) if use_api_key && str str = str.gsub(api_key,'[SECRET]') end str end |