Class: YleTf::System::OutputLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/yle_tf/system/output_logger.rb

Direct Known Subclasses

TfHookOutputLogger

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level) ⇒ OutputLogger

Returns a new instance of OutputLogger.

Raises:



8
9
10
11
12
# File 'lib/yle_tf/system/output_logger.rb', line 8

def initialize(level)
  @level = level.to_sym

  raise YleTf::Error, "Unknown log level '#{@level}'" if !level?(@level)
end

Instance Attribute Details

#levelObject (readonly)

Returns the value of attribute level.



6
7
8
# File 'lib/yle_tf/system/output_logger.rb', line 6

def level
  @level
end

Instance Method Details

#call(io, progname) ⇒ Object



14
15
16
17
18
# File 'lib/yle_tf/system/output_logger.rb', line 14

def call(io, progname)
  Thread.new do
    io.each { |line| log(progname, line.chomp) }
  end
end

#level?(level) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/yle_tf/system/output_logger.rb', line 20

def level?(level)
  YleTf::Logger::LEVELS.include?(level)
end

#log(progname, line) ⇒ Object



24
25
26
# File 'lib/yle_tf/system/output_logger.rb', line 24

def log(progname, line)
  YleTf::Logger.public_send(level, progname) { line }
end