Sha256: 911a2b8ab70cf5bebc7f325e1bb13f95c4f0f3a693b9782bdf3a8efebd40927c

Contents?: true

Size: 904 Bytes

Versions: 3

Compression:

Stored size: 904 Bytes

Contents

require 'thread'
require 'io/wait'
module OrigenSim
  class StderrReader < Thread
    attr_reader :socket, :logged_errors

    def initialize(socket)
      @socket = socket
      @continue = true
      @logged_errors = false
      super do
        while @continue
          while @socket.ready?
            line = @socket.gets.chomp
            if OrigenSim.fail_on_stderr && !line.empty? &&
               !OrigenSim.stderr_string_exceptions.any? { |s| line =~ /#{s}/ }
              # We're failing on stderr, so print its results and log as errors if its not an exception.
              @logged_errors = true
              Origen.log.error "(STDERR): #{line}"
            elsif OrigenSim.verbose?
              Origen.log.info line
            else
              Origen.log.debug line
            end
          end
        end
      end
    end

    def stop
      @continue = false
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
origen_sim-0.12.0 lib/origen_sim/stderr_reader.rb
origen_sim-0.11.1 lib/origen_sim/stderr_reader.rb
origen_sim-0.11.0 lib/origen_sim/stderr_reader.rb