<commit_before>module Comsat
  class Client
    attr_accessor :routes

    def initialize
      @@routes = []
    end

    def routes
      @@routes
    end

    def create_route(route, event_type, services)
      start = Time.now
      Comsat.log(:fn => :create_route, :at => :start)
      unless routes.detect {|r| r.name == route }
        routes << Route.new(route, event_type, services)
      end
      Comsat.log(:fn => :create_route, :at => :finish, :elapsed => Time.now - start)
    end

    def notify(route, message={})
      start = Time.now
      Comsat.log(:fn => :notify, :at => :start)
      notify_route = @@routes.detect {|r| r.name == route } if message
      event = notify_route.event_type
      notify_route.services.each do |svc|
        Comsat.log(:fn => :notify, :service => "#{svc.class.to_s.downcase}", :event => event)
        svc.send("send_#{event}".to_sym, message)
      end
      Comsat.log(:fn => :notify, :at => :finish, :elapsed => Time.now - start)
    end

    def send_notice(data)
      send_event(:notice, data)
    end

    def send_alert(data)
      send_event(:alert, data)
    end

    def send_resolve(data)
      send_event(:resolve, data)
    end

    private

    def send_event(event_type, data)
      @urls.each do |url|
        service = ServiceFactory.create(url)
        if service.respond_to?("send_#{event_type}")
          service.send("send_#{event_type}".to_sym, data)
        else
          next
        end<commit_msg>Clean up some logging.<commit_after>module Comsat
  class Client
    attr_accessor :routes

    def initialize
      @@routes = []
    end

    def routes
      @@routes
    end

    def create_route(route, event_type, services)
      start = Time.now
      Comsat.log(:fn => :create_route, :route => "#{route}", :at => :start)
      unless routes.detect {|r| r.name == route }
        routes << Route.new(route, event_type, services)
      end
      Comsat.log(:fn => :create_route, :route => "#{route}", :at => :finish, :elapsed => Time.now - start)
    end

    def notify(route, message={})
      start = Time.now
      Comsat.log(:fn => :notify, :route => "#{route}", :at => :start)
      notify_route = @@routes.detect {|r| r.name == route } if message
      event = notify_route.event_type
      notify_route.services.each do |svc|
        Comsat.log(:fn => :notify, :service => "#{svc.class.to_s.downcase}", :event => event)
        svc.send("send_#{event}".to_sym, message)
      end
      Comsat.log(:fn => :notify, :route => "#{route}", :at => :finish, :elapsed => Time.now - start)
    end

    def send_notice(data)
      send_event(:notice, data)
    end

    def send_alert(data)
      send_event(:alert, data)
    end

    def send_resolve(data)
      send_event(:resolve, data)
    end

    private

    def send_event(event_type, data)
      @urls.each do |url|
        service = ServiceFactory.create(url)
        if service.respond_to?("send_#{event_type}")
          service.send("send_#{event_type}".to_sym, data)
        else
          next
        end
{'fraction_non_alphanumeric': 0.14182771044873896, 'fraction_numerical': 0.0, 'mean_word_length': 2.490285714285714, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4360925', 'n_tokens_mistral': 1006, 'n_tokens_neox': 1001, 'n_words': 232}