Class: MonoLogger::LocklessLogDevice
- Inherits:
-
LogDevice
- Object
- LogDevice
- MonoLogger::LocklessLogDevice
- Defined in:
- lib/mono_logger.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(log = nil) ⇒ LocklessLogDevice
constructor
A new instance of LocklessLogDevice.
- #write(message) ⇒ Object
Constructor Details
#initialize(log = nil) ⇒ LocklessLogDevice
Returns a new instance of LocklessLogDevice.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mono_logger.rb', line 41 def initialize(log = nil) @dev = @filename = @shift_age = @shift_size = nil if log.respond_to?(:write) and log.respond_to?(:close) @dev = log else @dev = open_logfile(log) @dev.sync = true @filename = log end end |
Instance Method Details
#close ⇒ Object
58 59 60 |
# File 'lib/mono_logger.rb', line 58 def close @dev.close rescue nil end |
#write(message) ⇒ Object
52 53 54 55 56 |
# File 'lib/mono_logger.rb', line 52 def write() @dev.write() rescue Exception => ignored warn("log writing failed. #{ignored}") end |