Class: LoggerExtension::MultiIOLogger
- Inherits:
-
Object
- Object
- LoggerExtension::MultiIOLogger
- Defined in:
- lib/logger_extension/multi_i_o_logger.rb
Defined Under Namespace
Classes: LogDeviceMutex
Instance Attribute Summary collapse
-
#default_formatter ⇒ Object
readonly
Returns the value of attribute default_formatter.
-
#default_progname ⇒ Object
Returns the value of attribute default_progname.
Instance Method Summary collapse
- #close ⇒ Object
- #datetime_format ⇒ Object
- #datetime_format=(format) ⇒ Object
-
#initialize(*targets) ⇒ MultiIOLogger
constructor
A new instance of MultiIOLogger.
- #write(*arguments) ⇒ Object
Constructor Details
#initialize(*targets) ⇒ MultiIOLogger
Returns a new instance of MultiIOLogger.
11 12 13 14 15 |
# File 'lib/logger_extension/multi_i_o_logger.rb', line 11 def initialize(*targets) @targets = targets @default_formatter = ::LoggerExtension::Formatter.new @mutex = LogDeviceMutex.new end |
Instance Attribute Details
#default_formatter ⇒ Object (readonly)
Returns the value of attribute default_formatter.
8 9 10 |
# File 'lib/logger_extension/multi_i_o_logger.rb', line 8 def default_formatter @default_formatter end |
#default_progname ⇒ Object
Returns the value of attribute default_progname.
9 10 11 |
# File 'lib/logger_extension/multi_i_o_logger.rb', line 9 def default_progname @default_progname end |
Instance Method Details
#close ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/logger_extension/multi_i_o_logger.rb', line 33 def close @targets.each do |target| begin @mutex.synchronize do target.close rescue nil end rescue Exception target.close rescue nil end end end |
#datetime_format ⇒ Object
45 46 47 |
# File 'lib/logger_extension/multi_i_o_logger.rb', line 45 def datetime_format default_formatter.datetime_format end |
#datetime_format=(format) ⇒ Object
49 50 51 |
# File 'lib/logger_extension/multi_i_o_logger.rb', line 49 def datetime_format=(format) default_formatter.datetime_format = format end |
#write(*arguments) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/logger_extension/multi_i_o_logger.rb', line 17 def write(*arguments) @targets.each { |target| begin @mutex.synchronize do begin target.write(*arguments) rescue log_exception('WARN', 'log writing failed.--->', $!) end end rescue Exception => ignored log_exception('WARN', 'log writing failed.--->', ignored) end } end |