Class: Ghaki::Logger::Null

Inherits:
Base show all
Extended by:
Bool::Accessors
Includes:
Bool::Options
Defined in:
lib/ghaki/logger/null.rb

Overview

Helper for writing logs to nowhere during testing.

Instance Attribute Summary

Attributes inherited from Base

#major, #minor

Attributes included from Liner

#box_char, #box_size

Attributes included from CoreExt::Logger

#logdev

Instance Method Summary collapse

Methods inherited from Base

#dup, #level=

Methods included from Liner

#box, #fatal_dump, #liner, #puts

Methods included from CoreExt::Logger

#bounce, #re_open, #rotate

Constructor Details

#initialize(_opts = {}) ⇒ Null

Constructor options:

allow_redirection

Allow redirection of STDOUT and STDERR. [default:false]



25
26
27
28
29
30
31
32
33
34
# File 'lib/ghaki/logger/null.rb', line 25

def initialize _opts={}
  opts = _opts.dup
  bool_option opts, false, :allow_redirection
  opts.delete(:allow_redirection)
  opts.delete(:log_device)
  opts.delete(:file_handle)
  opts[:file_handle] = StringIO.new
  @keep_fname = opts.delete(:file_name)
  super( opts )
end

Instance Method Details

#filenameObject Also known as: file_name

Return captured filename.



37
38
39
# File 'lib/ghaki/logger/null.rb', line 37

def filename
  @keep_fname
end

#re_stderrObject

Reassign STDERR but only if redirection is allowed.



48
49
50
# File 'lib/ghaki/logger/null.rb', line 48

def re_stderr
  super if allow_redirection?
end

#re_stdoutObject

Reassign STDOUT but only if redirection is allowed.



53
54
55
# File 'lib/ghaki/logger/null.rb', line 53

def re_stdout
  super if allow_redirection?
end

#re_stdsObject

Reassign STDOUT and STDERR but only if redirection is allowed.



43
44
45
# File 'lib/ghaki/logger/null.rb', line 43

def re_stds
  super if allow_redirection?
end