Class: Celluloid::IncidentReporter
- Inherits:
-
Object
- Object
- Celluloid::IncidentReporter
- Includes:
- Celluloid, Notifications
- Defined in:
- lib/celluloid/logging/incident_reporter.rb
Overview
Subscribes to log incident topics to report on them.
Defined Under Namespace
Classes: Formatter
Constant Summary
Constants included from Celluloid
BARE_OBJECT_WARNING_MESSAGE, LINKING_TIMEOUT, OWNER_IVAR, VERSION
Instance Method Summary collapse
-
#initialize(*args) ⇒ IncidentReporter
constructor
A new instance of IncidentReporter.
- #report(_topic, incident) ⇒ Object
- #silence ⇒ Object
- #silenced? ⇒ Boolean
- #unsilence ⇒ Object
Methods included from Notifications
notifier, publish, #subscribe, #unsubscribe
Methods included from Celluloid
#abort, actor?, #after, #async, boot, #call_chain_id, cores, #current_actor, #defer, detect_recursion, #every, exception_handler, #exclusive, #exclusive?, #future, included, init, #link, #linked_to?, #links, mailbox, #monitor, #monitoring?, public_registry, publish, #receive, register_shutdown, running?, shutdown, #signal, #sleep, stack_dump, stack_summary, start, supervise, suspend, #tasks, #terminate, #timeout, #unlink, #unmonitor, uuid, version, #wait
Constructor Details
#initialize(*args) ⇒ IncidentReporter
Returns a new instance of IncidentReporter.
16 17 18 19 20 21 |
# File 'lib/celluloid/logging/incident_reporter.rb', line 16 def initialize(*args) subscribe(/log\.incident/, :report) @logger = ::Logger.new(*args) @logger.formatter = Formatter.new @silenced = false end |
Instance Method Details
#report(_topic, incident) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/celluloid/logging/incident_reporter.rb', line 23 def report(_topic, incident) return if @silenced header = "INCIDENT" header << " AT #{incident.triggering_event.time}" if incident.triggering_event @logger << header @logger << "\n" @logger << "====================\n" incident.events.each do |event| @logger.add(event.severity, event, event.progname) end @logger << "====================\n" end |
#silence ⇒ Object
37 38 39 |
# File 'lib/celluloid/logging/incident_reporter.rb', line 37 def silence @silenced = true end |
#silenced? ⇒ Boolean
45 46 47 |
# File 'lib/celluloid/logging/incident_reporter.rb', line 45 def silenced? @silenced end |
#unsilence ⇒ Object
41 42 43 |
# File 'lib/celluloid/logging/incident_reporter.rb', line 41 def unsilence @silenced = false end |