Class: Logger::LoggerIO

Inherits:
Object show all
Defined in:
lib/utilrb/logger/io.rb

Overview

An IO-like interface for a logger object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger, level) ⇒ LoggerIO

Returns a new instance of LoggerIO.



7
8
9
10
# File 'lib/utilrb/logger/io.rb', line 7

def initialize(logger, level)
    @logger, @level = logger, level
    @buffer = ''
end

Instance Attribute Details

#levelObject (readonly)

Returns the value of attribute level.



5
6
7
# File 'lib/utilrb/logger/io.rb', line 5

def level
  @level
end

#loggerObject (readonly)

Returns the value of attribute logger.



4
5
6
# File 'lib/utilrb/logger/io.rb', line 4

def logger
  @logger
end

Instance Method Details



16
17
18
# File 'lib/utilrb/logger/io.rb', line 16

def print(*msg)
    @buffer << msg.join("")
end

#puts(*msg) ⇒ Object



11
12
13
14
15
# File 'lib/utilrb/logger/io.rb', line 11

def puts(*msg)
    print msg
    logger.send(level, @buffer)
    @buffer = ''
end