<commit_before>module Opentsdb
  module Device
    module Collector
      module CLI
        class Run
          def initialize(options)
            @options = options
            @running = true

            dispatch
          end

          def dispatch
            setup_logging
            setup_traps
            setup_actors
            start_main_loop
          end

          def setup_logging
            require 'logger'
            ::Celluloid.logger = ::Logger.new('/var/log/opentsdb-device-collector.log')
          end

          def setup_traps
            # Workaround for https://github.com/celluloid/celluloid/pull/121
            output, input = IO.pipe

            Thread.new do
              while output.read(1)
                @running = false
                @master.terminate if @master
              end
            end

            [ 'TERM', 'INT' ].each do |signal|
              Signal.trap(signal) do<commit_msg>added the ability to specify a logfile in the config<commit_after>module Opentsdb
  module Device
    module Collector
      module CLI
        class Run
          def initialize(options)
            @options = options
            @running = true

            dispatch
          end

          def dispatch
            setup_logging
            setup_traps
            setup_actors
            start_main_loop
          end

          def setup_logging
            require 'logger'
            ::Celluloid.logger = ::Logger.new(@options['log_file'] || '/var/log//opentsdb-device-collector.log')
          end

          def setup_traps
            # Workaround for https://github.com/celluloid/celluloid/pull/121
            output, input = IO.pipe

            Thread.new do
              while output.read(1)
                @running = false
                @master.terminate if @master
              end
            end

            [ 'TERM', 'INT' ].each do |signal|
              Signal.trap(signal) do
{'fraction_non_alphanumeric': 0.06769230769230769, 'fraction_numerical': 0.0041025641025641026, 'mean_word_length': 1.271245634458673, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3819212', 'n_tokens_mistral': 507, 'n_tokens_neox': 480, 'n_words': 125}