Class: StringLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/string_logger.rb

Overview

Logs to a string. This is useful in testing so that we can read back what was put into the log, to see if it was what was expected.

Instance Method Summary collapse

Constructor Details

#initialize(*params) ⇒ StringLogger



5
6
7
# File 'lib/string_logger.rb', line 5

def initialize(*params)
  @log = StringIO.new("", "w")
end

Instance Method Details

#closeObject



8
9
# File 'lib/string_logger.rb', line 8

def close
end

#puts(msg) ⇒ Object Also known as: debug, info, notice, warning, err, alert, emerg, crit



11
12
13
# File 'lib/string_logger.rb', line 11

def puts(msg)
  @log.puts(msg)
end

#stringObject



15
16
17
# File 'lib/string_logger.rb', line 15

def string
  @log.string
end