Class: Fluent::Logger::ConsoleLogger
- Inherits:
-
TextLogger
- Object
- LoggerBase
- TextLogger
- Fluent::Logger::ConsoleLogger
- Defined in:
- lib/fluent/logger/console_logger.rb
Instance Attribute Summary collapse
-
#time_format ⇒ Object
Returns the value of attribute time_format.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(out) ⇒ ConsoleLogger
constructor
A new instance of ConsoleLogger.
- #post_text(text) ⇒ Object
- #reopen! ⇒ Object
Methods inherited from TextLogger
Methods inherited from LoggerBase
Constructor Details
#initialize(out) ⇒ ConsoleLogger
Returns a new instance of ConsoleLogger.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fluent/logger/console_logger.rb', line 23 def initialize(out) super() require 'time' if out.is_a?(String) @io = File.open(out, "a") @on_reopen = Proc.new { @io.reopen(out, "a") } elsif out.respond_to?(:write) @io = out @on_reopen = Proc.new { } else raise "Invalid output: #{out.inspect}" end end |
Instance Attribute Details
#time_format ⇒ Object
Returns the value of attribute time_format.
38 39 40 |
# File 'lib/fluent/logger/console_logger.rb', line 38 def time_format @time_format end |
Instance Method Details
#close ⇒ Object
48 49 50 51 |
# File 'lib/fluent/logger/console_logger.rb', line 48 def close @io.close self end |
#post_text(text) ⇒ Object
44 45 46 |
# File 'lib/fluent/logger/console_logger.rb', line 44 def post_text(text) @io.puts text end |
#reopen! ⇒ Object
40 41 42 |
# File 'lib/fluent/logger/console_logger.rb', line 40 def reopen! @on_reopen.call end |