Class: Cfruby::Cfp_FlowMonitor
- Inherits:
-
FlowMonitor::Observer
- Object
- FlowMonitor::Observer
- Cfruby::Cfp_FlowMonitor
- Defined in:
- lib/libcfenjin/cfp_flowmonitor.rb
Instance Method Summary collapse
-
#handle_message(message) ⇒ Object
Every message from any controller this observer is registered with is passed through handle_message.
-
#initialize(logger) ⇒ Cfp_FlowMonitor
constructor
A new instance of Cfp_FlowMonitor.
Constructor Details
#initialize(logger) ⇒ Cfp_FlowMonitor
Returns a new instance of Cfp_FlowMonitor.
11 12 13 14 |
# File 'lib/libcfenjin/cfp_flowmonitor.rb', line 11 def initialize(logger) @logger = logger Cfruby.controller.register(self) end |
Instance Method Details
#handle_message(message) ⇒ Object
Every message from any controller this observer is registered with is passed through handle_message. This is a simple implementation that logs every message, and
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/libcfenjin/cfp_flowmonitor.rb', line 19 def () if(.type == 'exception') @logger.error(LOG_ERR,.) return() end # If the message has a type of intention, then we have the chance to # basically say "NO" to the action. In this case we are going to # say no to any intention that references the filename 'notouch'. We could # in theory filter on any aspect of the message (the type, the tags, or # the content of the message itself), but in this case a simple regex hack # for example purposes will do nicely if(.type == 'intention') # we can only really block intentions, so only bother checking # if the message is an intention @logger.notify(VERBOSE_MAJOR,.) elsif (.type == 'info') if(. =~ /^search|lock|backup/) # overrule status of these @logger.notify(VERBOSE_MINOR,.) else @logger.notify(VERBOSE_CRITICAL,.) end elsif (.type == 'verbose') @logger.notify(VERBOSE_MAJOR,.) elsif (.type == 'debug') @logger.notify(VERBOSE_MINOR,.) else @logger.notify(VERBOSE_MINOR,.) end true end |