Class: MonoLogger::LocklessLogDevice

Inherits:
LogDevice
  • Object
show all
Defined in:
lib/chef/monologger.rb

Instance Method Summary collapse

Constructor Details

#initialize(log = nil) ⇒ LocklessLogDevice

Returns a new instance of LocklessLogDevice


43
44
45
46
47
48
49
50
51
52
# File 'lib/chef/monologger.rb', line 43

def initialize(log = nil)
  @dev = @filename = @shift_age = @shift_size = nil
  if log.respond_to?(:write) && log.respond_to?(:close)
    @dev = log
  else
    @dev = open_logfile(log)
    @filename = log
  end
  @dev.sync = true
end

Instance Method Details

#closeObject


60
61
62
# File 'lib/chef/monologger.rb', line 60

def close
  @dev.close rescue nil
end

#write(message) ⇒ Object


54
55
56
57
58
# File 'lib/chef/monologger.rb', line 54

def write(message)
  @dev.write(message)
rescue Exception => ignored
  warn("log writing failed. #{ignored}")
end