Class: MemoryLogger::Logger

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogger



12
13
14
15
# File 'lib/memory_logger.rb', line 12

def initialize
  @io = StringIO.new
  @logger = Logger.new(@io)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



8
9
10
# File 'lib/memory_logger.rb', line 8

def method_missing(sym, *args, &block)
  logger.send(sym, *args, &block)
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



6
7
8
# File 'lib/memory_logger.rb', line 6

def logger
  @logger
end

Instance Method Details

#logged_outputObject



17
18
19
# File 'lib/memory_logger.rb', line 17

def logged_output
  @io.string
end

#messagesObject



21
22
23
# File 'lib/memory_logger.rb', line 21

def messages
  logged_output.split("\n")
end