Class: Vedeu::Logging::LocklessLogDevice Private
- Inherits:
-
Logger::LogDevice
- Object
- Logger::LogDevice
- Vedeu::Logging::LocklessLogDevice
- Defined in:
- lib/vedeu/logging/lockless_log_device.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Ensures we can always write to the log file by creating a lock-less log device.
Instance Method Summary collapse
- #close ⇒ void private
-
#initialize(log = nil) ⇒ Vedeu::Logging::LocklessLogDevice
constructor
private
Returns a new instance of Vedeu::Logging::LocklessLogDevice.
- #open_logfile(log) ⇒ void private private
- #write(message) ⇒ void private
Constructor Details
#initialize(log = nil) ⇒ Vedeu::Logging::LocklessLogDevice
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Vedeu::Logging::LocklessLogDevice.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vedeu/logging/lockless_log_device.rb', line 18 def initialize(log = nil) @dev = nil @filename = nil if log.respond_to?(:write) && log.respond_to?(:close) @dev = log else @dev = open_logfile(log) @dev.sync = true @filename = log end end |
Instance Method Details
#close ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
43 44 45 46 47 |
# File 'lib/vedeu/logging/lockless_log_device.rb', line 43 def close @dev.close rescue nil end |
#open_logfile(log) ⇒ void (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/vedeu/logging/lockless_log_device.rb', line 53 def open_logfile(log) if FileTest.exist?(log) open(log, (File::WRONLY | File::APPEND)) else logdev = open(log, (File::WRONLY | File::APPEND | File::CREAT)) logdev.sync = true logdev end end |
#write(message) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
35 36 37 38 39 40 |
# File 'lib/vedeu/logging/lockless_log_device.rb', line 35 def write() @dev.write() rescue StandardError => exception warn("log writing failed. #{exception}") end |