Changeset 612

Show
Ignore:
Timestamp:
04/23/07 16:29:20 (2 years ago)
Author:
sacha
Message:

some logging improvements

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/hefeweizen_big_ania.rb

    r604 r612  
    371371    def listen_to_ania 
    372372      command = nil 
     373      # endless loop of big ania. Will always listen to the queue 
    373374      while true do 
    374375        begin 
    375376          while (command = $pipe_to_me.readline) do 
    376             #            puts "XXbeginXXXXX:#{command.strip}" 
    377             #            @logger.debug "Command received: #{command.strip}" if @debug 
     377            # @logger.debug "Command received: #{command.strip}" if @debug 
    378378            processed = process_command_from_ania command 
    379             #            puts "XXendXXXXXXX:#{command.strip}" 
    380             #            @logger.debug "Command processed: #{command.strip}" if @debug 
    381379            if @exit == true then 
    382380              return 0 
     
    384382          end 
    385383        rescue EOFError => error 
    386           puts "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 
    387           puts "BIG ANIA PIPE ERROR: #{error.to_s}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 
    388           puts "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 
     384          @logger.error "#{me} Big Ania Reading Pipe Error: #{error.inspect}" if @error 
    389385          sleep 0.1 
    390386        end 
     
    403399        command_hash = HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.command_to_hash command 
    404400        if command_hash.nil? then 
    405           @logger.error "#{me}: Unable to convert the command to a hash. This indicates the the command was incomplete or unknown. Command was: #{command}" 
     401          @logger.error "#{me}: Unable to convert the command to a hash. This indicates the the command " +  
     402            "was incomplete or unknown. Command was: #{command}" if @error 
    406403          processed = false 
    407404        else 
    408405          command = command_hash['command'] 
    409            
    410406          if !command.nil? and !command.empty? then 
    411407            if !command_hash['transaction_id'].nil? then 
     
    420416                  end 
    421417                end 
    422                 # regular testing 
    423418                b2b_system = @b2b_systems[command_hash['b2b_system_name']] 
    424419                if b2b_system.nil? then  
    425                   @logger.error "#{me}: Error getting the b2b system from the command: #{command}." 
     420                  @logger.error "#{me}: Error getting the b2b system from the command: #{command}." if @error 
    426421                  processed = false 
    427422                else 
     
    431426                  new_command = nil 
    432427                  begin 
    433                     (processed, new_command = b2b_system.process_command( transaction, command, command_hash )) if !processed 
     428                    (processed, new_command = b2b_system.process_command( transaction, command, command_hash )) unless processed 
    434429                    if processed == true then 
    435                       @logger.debug "#{me}: Successfully processed command '#{command}'." if @debug 
     430                      @logger.info "#{me}: Successfully processed command '#{command}'." if @debug 
    436431                      if new_command then 
    437432                        @logger.debug "#{me}: Sending new command to ania. command: '#{new_command}'." if @debug 
    438433                        say_to_ania new_command 
    439434                      end 
     435                    else 
     436                      @logger.warn "#{me}: Unsuccessfully processed command '#{command}'." if @warn 
     437                      # questions: 
     438                      #  o close transaction? 
     439                      #  o fail transaction? 
    440440                    end 
    441441                  rescue Exception => e 
    442                     @logger.error "#{me}: Unexpected and unhandled error happened. The system may have become unstable. Error: #{e.to_s}." 
    443                     @logger.error "#{me}: Error time: #{Time.now}." 
    444                     @logger.error "#{me}: Error traceback: #{e.backtrace}." 
     442                    @logger.error "#{me}: Unexpected and unhandled error happened. The system may have become unstable. Error: #{e.to_s}." if @error 
     443                    @logger.error "#{me}: Error time: #{Time.now}." if @error 
     444                    @logger.error "#{me}: Error traceback: #{e.backtrace}." if @error 
    445445                  end 
    446446                end 
    447447              else 
    448                 @logger.error "#{me}: Error getting a transaction for command: #{command}." 
     448                @logger.error "#{me}: Error getting a transaction for command: #{command}." if @error 
    449449                processed = false 
    450450              end 
    451451            else 
    452               @logger.error "#{me}: Error missing transaction id in the command. Every command must have a transaction id." 
     452              @logger.error "#{me}: Error missing transaction id in the command. Every command must have a transaction id." if @error 
    453453              processed = false 
    454454            end