Module: Log

Defined in:
lib/rbbt/util/log/refactor.rb

Class Method Summary collapse

Class Method Details

._ignore_stderrObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rbbt/util/log/refactor.rb', line 3

def self._ignore_stderr
  begin
    File.open('/dev/null', 'w') do |f|
      backup_stderr = STDERR.dup
      STDERR.reopen(f)
      begin
        yield
      ensure
        STDERR.reopen backup_stderr
        backup_stderr.close
      end
    end
  rescue Errno::ENOENT
    yield
  end
end

._ignore_stdoutObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rbbt/util/log/refactor.rb', line 25

def self._ignore_stdout
  begin
    File.open('/dev/null', 'w') do |f|
      backup_stdout = STDOUT.dup
      STDOUT.reopen(f)
      begin
        yield
      ensure
        STDOUT.reopen backup_stdout
        backup_stdout.close
      end
    end
  rescue Errno::ENOENT
    yield
  end
end

.ignore_stderr(&block) ⇒ Object



21
22
23
# File 'lib/rbbt/util/log/refactor.rb', line 21

def self.ignore_stderr(&block)
  _ignore_stderr &block
end

.ignore_stdout(&block) ⇒ Object



43
44
45
# File 'lib/rbbt/util/log/refactor.rb', line 43

def self.ignore_stdout(&block)
  _ignore_stdout &block
end