Class: YleTf::System::TfHookOutputLogger
- Inherits:
-
OutputLogger
- Object
- OutputLogger
- YleTf::System::TfHookOutputLogger
- Defined in:
- lib/yle_tf/system/tf_hook_output_logger.rb
Overview
An IO handler class for YleTf Hook output.
Allows hooks to emit log messages with specific levels by prefixing a line with ‘<LEVEL>: `.
Instance Attribute Summary
Attributes inherited from OutputLogger
Instance Method Summary collapse
-
#line_level(line) ⇒ Object
Extracts the log level from the line if found, otherwise returns the default level and the line as is.
- #log(progname, line) ⇒ Object
Methods inherited from OutputLogger
Constructor Details
This class inherits a constructor from YleTf::System::OutputLogger
Instance Method Details
#line_level(line) ⇒ Object
Extracts the log level from the line if found, otherwise returns the default level and the line as is
23 24 25 26 27 28 29 30 |
# File 'lib/yle_tf/system/tf_hook_output_logger.rb', line 23 def line_level(line) if (m = /^(?<level>[A-Z]+): (?<line>.*)$/.match(line)) line_level = m[:level].downcase.to_sym return [line_level, m[:line]] if level?(line_level) end [level, line] end |
#log(progname, line) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/yle_tf/system/tf_hook_output_logger.rb', line 11 def log(progname, line) # Remove `[<progname>] ` prefix from the output line. # This is mostly for backwards compatibility in Yle. line.sub!(/^\[#{progname}\] /, '') level, line = line_level(line) YleTf::Logger.public_send(level, progname) { line } end |