Class: YleTf::System::OutputLogger
- Inherits:
-
Object
- Object
- YleTf::System::OutputLogger
- Defined in:
- lib/yle_tf/system/output_logger.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Returns the value of attribute level.
Instance Method Summary collapse
- #call(io, progname) ⇒ Object
-
#initialize(level) ⇒ OutputLogger
constructor
A new instance of OutputLogger.
- #level?(level) ⇒ Boolean
- #log(progname, line) ⇒ Object
Constructor Details
#initialize(level) ⇒ OutputLogger
Returns a new instance of OutputLogger.
10 11 12 13 14 |
# File 'lib/yle_tf/system/output_logger.rb', line 10 def initialize(level) @level = level.to_sym raise YleTf::Error, "Unknown log level '#{@level}'" if !level?(@level) end |
Instance Attribute Details
#level ⇒ Object (readonly)
Returns the value of attribute level.
8 9 10 |
# File 'lib/yle_tf/system/output_logger.rb', line 8 def level @level end |
Instance Method Details
#call(io, progname) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/yle_tf/system/output_logger.rb', line 16 def call(io, progname) Thread.new do begin io.each { |line| log(progname, line.chomp) } rescue IOError => e YleTf::Logger.debug e. end end end |
#level?(level) ⇒ Boolean
26 27 28 |
# File 'lib/yle_tf/system/output_logger.rb', line 26 def level?(level) YleTf::Logger::LEVELS.include?(level) end |
#log(progname, line) ⇒ Object
30 31 32 |
# File 'lib/yle_tf/system/output_logger.rb', line 30 def log(progname, line) YleTf::Logger.public_send(level, progname) { line } end |