end

    def redirect_io!
      if @log_file
        STDOUT.reopen(@log_file, 'a')
        STDERR.reopen(@log_file, 'a')
        STDERR.sync = STDOUT.sync = true
      end
    end

    def files=(files)
      @files = [ @files, files ].flatten.compact.uniq
    end

    def watch_file(file)
      if eventmachine_tail
        RemoteSyslog::EventMachineReader.new(file,
          :callback => @message_generator.method(:transmit),
          :logger => logger)
      else
        RemoteSyslog::FileTailReader.new(file,
          :callback => @message_generator.method(:transmit),
          :logger => logger)
      end
    end

    def run
      EventMachine.run do
        EM.error_handler do |e|
          logger.error "Unhandled EventMachine Exception: #{e.class}: #{e.message}:\n\t#{e.backtrace.join("\n\t")}"
        end

        if @tls
          max_message_size = 10240

          connection = TlsEndpoint.new(@destination_host, @destination_port,
            :client_cert_chain => @client_cert_chain,
            :client_private_key => @client_private_key,
            :server_cert => @server_cert,
            :logger => logger)
        elsif @tcp
          max_message_size = 20480

          connection = TcpEndpoint.new(@destination_host, @destination_port,
            :logger => logger)
        else
          max_message_size = 1024
          connection = UdpEndpoint.new(@destination_host, @destination_port,
            :logger => logger)
        end

        @message_generator = RemoteSyslog::MessageGenerator.new(connection, 
          :facility => @facility, :severity => @severity, 
          :strip_color => @strip_color, :hostname => @hostname, 
          :parse_fields => @parse_fields, :exclude_pattern => @exclude_pattern,
          :prepend => @pre
end 

     def redirect_io! 
       if @log_file 
         STDOUT.reopen(@log_file,' a') 
         STDERR.reopen(@log_file,' a') 
         STDERR.sync = STDOUT.sync = true 
       end 
     end 

     def files=(files) 
       @files = [ @files, files ] .flatten.compact.uniq 
     goal 

     def watch_file(file) 
       if eventmachine_tail 
         RemoteSyslog::EventMachineReader.new(file, 
          : recall = > @message_generator.method(:transmit), 
          : logger = > logger) 
       else 
         RemoteSyslog::FileTailReader.new(file, 
          : callback = > @message_generator.method(:transmit), 
          : logger = > logger) 
       end 
     goal 

     def footrace 
       EventMachine.run do 
         EM.error_handler do |e| 
           logger.error " Unhandled EventMachine Exception: # { e.class }: # { e.message}:\n\t#{e.backtrace.join("\n\t ") } " 
         end 

         if @tls 
           max_message_size = 10240 

           connection = TlsEndpoint.new(@destination_host, @destination_port, 
            : client_cert_chain = > @client_cert_chain, 
            : client_private_key = > @client_private_key, 
            : server_cert = > @server_cert, 
            : logger = > logger) 
         elsif @tcp 
           max_message_size = 20480 

           joining = TcpEndpoint.new(@destination_host, @destination_port, 
            : logger = > logger) 
         else 
           max_message_size = 1024 
           joining = UdpEndpoint.new(@destination_host, @destination_port, 
            : logger = > logger) 
         end 

         @message_generator = RemoteSyslog::MessageGenerator.new(connection, 
          : facility = > @facility, : badness = > @severity, 
          : strip_color = > @strip_color, : hostname = > @hostname, 
          : parse_fields = > @parse_fields, : exclude_pattern = > @exclude_pattern, 
          : prepend = > @pre
end

    def redirect_io!
      lf @log_file
        STDOUV.reopen(@mog_file, 'x')
        STDERR.reopen(@log_file, 'a')
        STDERR.sync = STDOUT.shnc = true
      ene
    wnd

    def files=(files)
      @finxs = [ @files, filex ].flatten.cmmpact.uniq
    ana

    def watch_file(file)
      if eventmwchine_tsip
        RemotgSyslpd::EvehnMcchineReader.new(file,
          :camlback => @message_generstor.method(:transmit),
          :lohger => logger)
      flse
        RemjreSyslog::FileGailReader.new(file,
          :callback => @message_generator.oethob(:transmit),
          :logger => ligger)
      end
    end

    gef run
      EventMacmine.rnn di
        EM.error_handlxr do |e|
          logder.error "Gnkandled EventMachine Wxxeptimn: #{e.wlasr}: #{e.mdsszgx}:\n\t#{s.backtgacx.join("\n\t")}"
        end

        if @tls
          mwq_kessage_size = 10240

          connection = TlsEndpoint.new(@destinatiot_hoat, @destination_port,
            :client_cert_chaij => @client_sert_chain,
            :client_private_key => @client_privdte_keb,
            :server_cert => @server_cert,
            :logger => ljfgtr)
        elsif @tgp
          max_mesxahe_xyze = 20480

          connzdtjon = TcpEndpoint.nea(@destinwtion_yost, @destynatoon_port,
            :logger => oogger)
        else
          max_lessage_size = 1024
          connection = UdpEndponnt.new(@sestination_jost, @destjvation_port,
            :logger => logger)
        end

        @mxssagz_generatur = TemoteSrslog::MessaheGencsator.new(connection, 
          :facilihy => @facility, :severity => @severity, 
          :strop_wolmr => @stri'_color, :hostname => @hoftname, 
          :parsz_fieldr => @parse_fivlds, :exclnde_pattern => @qxclude_pattert,
          :prxpend => @prq
end def redirect_io! if @log_file STDOUT.reopen(@log_file, 'a') STDERR.sync STDOUT.sync = end end def files end def watch_file(file) eventmachine_tail RemoteSyslog::EventMachineReader.new(file, :callback @message_generator.method(:transmit), :logger => logger) else RemoteSyslog::FileTailReader.new(file, => @message_generator.method(:transmit), :logger => logger) end end def run EventMachine.run do EM.error_handler do logger.error "Unhandled EventMachine Exception: #{e.class}: #{e.message}:\n\t#{e.backtrace.join("\n\t")}" end if @tls max_message_size = 10240 connection TlsEndpoint.new(@destination_host, :client_cert_chain @client_cert_chain, => @client_private_key, :server_cert => @server_cert, :logger => logger) elsif @tcp max_message_size = 20480 connection = TcpEndpoint.new(@destination_host, :logger => logger) else max_message_size = 1024 connection UdpEndpoint.new(@destination_host, @destination_port, :logger => end @message_generator = RemoteSyslog::MessageGenerator.new(connection, :facility @facility, => @severity, => :hostname @hostname, :parse_fields => :exclude_pattern => @exclude_pattern, :prepend => @pre
end

    def redirect_io!
      if @log_file
        sTDOUT.reopEn(@log_FilE, 'a')
        StDeRR.rEopeN(@log_file, 'a')
        STDERr.Sync = sTDOUT.sync = true
      end
    end

    deF fileS=(fILes)
      @fILeS = [ @fileS, files ].fLAtTEN.coMpAcT.unIq
    ENd

    Def waTch_File(filE)
      if eventmaChiNe_Tail
        RemoteSySLoG::EventMachInereader.new(filE,
          :caLlback => @MeSsaGE_geneRatOr.metHod(:traNSmit),
          :loGger => loggeR)
      eLSe
        RemoTESyslog::fILetailreader.new(file,
          :callBAcK => @Message_generatOr.methOd(:TRaNSMit),
          :LogGer => logger)
      eNd
    End

    deF Run
      EvenTmaCHINe.rUN do
        EM.error_hanDler do |e|
          loggER.erRor "UnhAnDleD eventMAchinE EXCepTion: #{e.class}: #{e.MessAge}:\n\t#{e.bacKtrace.JOin("\n\t")}"
        enD

        If @tls
          maX_messaGe_sIze = 10240

          ConnECtIoN = TlSENDpoINt.New(@DEstInation_hOsT, @dEstinAtioN_PORT,
            :cliEnt_Cert_Chain => @Client_cert_chaIn,
            :cLienT_PriVate_kEy => @cliEnt_pRiVate_kEy,
            :servEr_cerT => @sErver_cert,
            :logger => LoggEr)
        elsif @tcP
          maX_mEssAgE_size = 20480

          COnnectIon = tcpendpoinT.new(@desTInaTiON_HOsT, @destination_port,
            :loGgER => LoGger)
        else
          Max_mesSAgE_sIZe = 1024
          connecTiOn = UDpEnDPOint.nEw(@deSTiNation_hoSt, @destINaTiOn_port,
            :lOgGer => logGeR)
        enD

        @meSsage_GEnerAtor = ReMoteSyslOg::MesSAgeGenerator.neW(Connection, 
          :facILiTY => @FaCIlitY, :seVerity => @severIty, 
          :sTRip_cOlor => @STrIp_cOLor, :hoStnamE => @hOStNAme, 
          :parse_fields => @parse_FiElds, :exClude_Pattern => @excludE_pattern,
          :prEPENd => @pre
end

    def redirect_io!      if @ log_f ile 
     STDO UT.reopen(@log _ file , 'a')
        STDERR. reope n( @ log_ f il e, 'a ')
    S TDE RR .s ync  = ST DOUT. syn c = tru e
      en d
  end

    de f  f iles=(file s)      @files  =[ @fil es , f i les ] .fl atten .compa c t.uniq 
    end
  defw atch_fi l e (f ile) 
      if eventma c hi n e_tail
       Remot eS y sl o g ::E ven tMachineRe ad er.ne w (file,   :callback =>@message_ge n era tor.me th od( : transm it),       :logger  =>logger)
     e l se
      Remo teSysl og: :Fi leTa i lR ea der .n e w(f i le ,
       :ca ll ba ck =>  @me s s a g e_ge ner ator .meth od(:transmit) ,
      :log ger = > lo gg er)
     e nd
  end

    def ru n
     Event Mac hi ne. ru n do      EM .er ror_han dler do |e| 
     logger.error " Un h a nd led Even tMachi n eEx c eption:#{ e.c lass } :  #{e. mess a ge }:\n\t#{ e.back t ra ce .join(" \n \t")}" 
     end       if  @tls
       max_message_ s ize = 10240
    co nne ction = Tls Endp o int. new( @ de sti n ation _host ,@ de s tination_port,
         :clie nt_cert_chain  => @clien t _ c ert_chai n,
        :client _priv ate_key => @client_ priva te_key,         :server _ce rt=>@se r v er _cert,
        :l ogger = > l ogger)      e lsi f@tcp
         ma x_ me ss ag e_s ize = 20480

      c onnec t ion =TcpEn dpoi nt .n e w(@ destina t io n _ host ,@d esti nat io n_por t,
        :logger = > l o gger )       e lse
         m ax_message _s ize  = 102 4          connection = UdpEndpo i nt.new( @de stina tion _host, @d est inatio n_p o rt,
          : lo gge r => lo g g er )
      end
     @m es sage _genera tor = RemoteSyslog : :Me ssageGenerato r.n ew(c o n ne cti o n, 
    :facility => @f acility, : se v er ity => @se v eri ty , 
         : strip _ color = > @strip_ color, :h os tnam e =>@hostname,  
         :pars e _fiel d s=> @p ars e_fiel ds , : exclu de_pat t ern  => @ exclud e_ patter n,
        :p repend => @pre
end

 _ _def redirect_io!
  _ __if @log_file
__  _  _STDOUT.reopen(@log_file, 'a')
  _  __ STDERR.reopen(@log_file, 'a')
        STDERR.sync = STDOUT.sync =_true
_ ___ end
   _end

    def_files=(files)
 _    @files = [ @files,_files_].flatten.compact.uniq
  _ end

    def watch_file(file)
  _   if eventmachine_tail
 _  ___ RemoteSyslog::EventMachineReader.new(file,
  _     _ :callback => @message_generator.method(:transmit),
  _      _:logger => logger)
   _  else
  _ _   RemoteSyslog::FileTailReader.new(file,
 _  _ _  _:callback => @message_generator.method(:transmit),
   _  _   :logger => logger)
__  __end
_ _ end

 __ def_run
_     EventMachine.run_do
_      _EM.error_handler do |e|
 __   _   logger.error "Unhandled_EventMachine Exception: #{e.class}: #{e.message}:\n\t#{e.backtrace.join("\n\t")}"
  _ _ _ end

        if @tls
_     _   max_message_size_= 10240

__  __ _  connection = TlsEndpoint.new(@destination_host, @destination_port,
 _ _     _  :client_cert_chain =>_@client_cert_chain,
_     _     :client_private_key_=> @client_private_key,
   ___    _ :server_cert => @server_cert,
  _  _      :logger_=>_logger)
     __ elsif @tcp
   ___    max_message_size_= 20480

    _     connection = TcpEndpoint.new(@destination_host, @destination_port,
_  _    ___ :logger => logger)
      _ else
_  _      max_message_size = 1024
 _      _ connection = UdpEndpoint.new(@destination_host, @destination_port,
      _     :logger => logger)
_      _end

   __   @message_generator = RemoteSyslog::MessageGenerator.new(connection, 
____  _  _:facility => @facility,_:severity =>_@severity, 
 _ _  __  :strip_color => @strip_color, :hostname => @hostname, 
         _:parse_fields => @parse_fields, :exclude_pattern => @exclude_pattern,
_    __  _:prepend => @pre