Module: WhoopsLogger

Defined in:
lib/whoops_logger/configuration.rb,
lib/whoops_logger.rb,
lib/whoops_logger/sender.rb,
lib/whoops_logger/message.rb,
lib/whoops_logger/strategy.rb,
lib/whoops_logger/message_creator.rb

Overview

Borrows heavily from Hoptoad Notifier by Tammer Saleh

Defined Under Namespace

Classes: Configuration, Message, MessageCreator, Sender, Strategy

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



13
14
15
# File 'lib/whoops_logger.rb', line 13

def config
  @config
end

.strategiesObject

Returns the value of attribute strategies.



13
14
15
# File 'lib/whoops_logger.rb', line 13

def strategies
  @strategies
end

Class Method Details

.log(raw_data) ⇒ Object .log(strategy_name, raw_data) ⇒ Object

Overloads:

  • .log(raw_data) ⇒ Object

    Notify using the default basic strategy

    Parameters:

    • raw_data (Hash)

      the raw_data expected by the basic strategy, used by strategy to build message

  • .log(strategy_name, raw_data) ⇒ Object

    Parameters:

    • strategy_name (Symbol, String)
    • raw_data (Hash)

      same as above



21
22
23
24
25
26
27
28
29
# File 'lib/whoops_logger.rb', line 21

def log(strategy_name, raw_data = {})
  if strategy_name.is_a? Hash
    log("default::basic", strategy_name)
  else
    message_creator = MessageCreator.new(strategies[strategy_name], raw_data)
    message_creator.create!
    send_message(message_creator.message) unless message_creator.ignore_message?
  end
end

.send_message(message) ⇒ Object



31
32
33
# File 'lib/whoops_logger.rb', line 31

def send_message(message)
  Sender.new(WhoopsLogger.config.to_hash).send_message(message.to_hash)
end