Customized Logger class that dispenses with the unnecessary mutexing. As long as you write one line at a time, the OS will take care of keeping your output in order. Expander commonly runs as a cluster of worker processes so the mutexing wasn't actually helping us anyway.
We don't use the program name field in the logger, so support for that has been removed. The log format is also hardcoded since we don't ever change the format.
# File lib/chef/expander/logger.rb, line 72 def <<(msg) @log_device.print(msg) end
# File lib/chef/expander/logger.rb, line 76 def add(severity=UNKNOWN, message = nil, progname = nil, &block) return true unless severity >= @level message ||= progname # level methods (e.g, #debug) pass explicit message as progname if message.nil? && block_given? message = yield end self << sprintf("[%s] %s: %s\n", Time.new.rfc2822(), LEVEL_TO_STR[severity], msg2str(message)) true end
(re-)initialize the Logger with a new IO object or file to log to.
# File lib/chef/expander/logger.rb, line 53 def init(log_device) @log_device = initialize_log_device(log_device) end
# File lib/chef/expander/logger.rb, line 62 def level=(new_level) @level = if new_level.kind_of?(Fixnum) && LEVEL_INTEGERS.key?(new_level) new elsif LEVELS.key?(new_level) LEVELS[new_level] else raise InvalidLogLevel, "#{new_level} is not a valid log level. Valid log levels are [#{LEVEL_INTEGERS.keys.join(',')}] and [#{LEVELS.join(',')}]" end end
Generated with the Darkfish Rdoc Generator 2.