Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Practical Logs. Vol 2

Practical Logs. Vol 2

how I keep improving on logs

Felipe Espinoza

November 07, 2016
Tweet

More Decks by Felipe Espinoza

Other Decks in Technology

Transcript

  1. Not able to cross information - What are the endpoints

    requested by a particular user? - which are the requests made by the iPhone client in a particular vesion? - Do you even use http caching bro? - Who are the most active users? Which status codes do they get back? - For a given request how many unique users have done this requests?
  2. - What are the endpoints requested by a particular user?

    - which are the requests made by the iPhone client in a particular vesion? - Do you even use http caching bro? - Who are the most active users? Which status codes do they get back? - For a given request how many unique users have done this requests? ✅ ✅ ✅ ✅ ✅
  3. # config/initializer/useful_logs.rb UsefulLogs.configure do |config| config.request_info_class_name = 'MyRequestInfo' end MyApp::Application.configure

    do config.lograge.enabled = true config.lograge.custom_options = lambda do |event| options = { mark: 'request' } MyRequestInfo.field_ids.each_with_object(options) do |field, data| data[field] = event.payload[field] end end config.lograge.formatter = lambda do |data| UsefulLogs::LogFormatter.key_value_pairs(data) end end
  4. module Logging module Token def self.log_token_error(id:, context:, error:, error_response:) token_error

    = { token_event: 'token_error', token_error: id, context: context, error: error, error_response: error_response } Rails.logger.error Logging.stringify(hash: token_error) end def self.log_token_warning(token_warning:, reason:) token_warning = { token_event: 'token_warning', token_warning: token_warning, reason: reason } Rails.logger.warn Logging.stringify(hash: token_warning) end end end Module/hash approach
 to log other events than requests