class Celluloid::IncidentReporter - celluloid-0.15.2 Documentation

# class Celluloid::IncidentReporter

Subscribes to log incident topics to report on them.

### Public Class Methods

new(*args) click to toggle source

    # File lib/celluloid/logging/incident_reporter.rb, line 15
    def initialize(*args)
      subscribe(/log\.incident/, :report)
      @logger = ::Logger.new(*args)
      @logger.formatter = Formatter.new
      @silenced = false
    end

### Public Instance Methods

report(topic, incident) click to toggle source

    # File lib/celluloid/logging/incident_reporter.rb, line 22
    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() click to toggle source

    # File lib/celluloid/logging/incident_reporter.rb, line 36
    def silence
      @silenced = true
    end

silenced?() click to toggle source

    # File lib/celluloid/logging/incident_reporter.rb, line 44
    def silenced?
      @silenced
    end

unsilence() click to toggle source

    # File lib/celluloid/logging/incident_reporter.rb, line 40
    def unsilence
      @silenced = false
    end