Class: Mixlib::Log::Logger
- Inherits:
-
Logger
- Object
- Logger
- Mixlib::Log::Logger
- Includes:
- Logging
- Defined in:
- lib/mixlib/log/logger.rb
Defined Under Namespace
Classes: LocklessLogDevice
Constant Summary
Constants included from Logging
Mixlib::Log::Logging::LEVELS, Mixlib::Log::Logging::LEVEL_NAMES, Mixlib::Log::Logging::SEV_LABEL, Mixlib::Log::Logging::TRACE
Instance Attribute Summary
Attributes included from Logging
Instance Method Summary collapse
- #add_data(severity, message, progname, data: {}) ⇒ Object (also: #add)
-
#initialize(logdev) ⇒ Logger
constructor
Synopsis.
- #trace? ⇒ Boolean
Methods included from Logging
Constructor Details
#initialize(logdev) ⇒ Logger
Synopsis
Logger.new(name, shift_age = 7, shift_size = 1048576)
Logger.new(name, shift_age = 'weekly')
Args
logdev
-
The log device. This is a filename (String) or IO object (typically $stdout, $stderr, or an open file).
shift_age
-
Number of old log files to keep, or frequency of rotation (
daily
,weekly
ormonthly
). shift_size
-
Maximum logfile size (only applies when
shift_age
is a number).
Description
Create an instance.
35 36 37 38 39 40 |
# File 'lib/mixlib/log/logger.rb', line 35 def initialize(logdev) super(nil) if logdev @logdev = LocklessLogDevice.new(logdev) end end |
Instance Method Details
#add_data(severity, message, progname, data: {}) ⇒ Object Also known as: add
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/mixlib/log/logger.rb', line 42 def add_data(severity, , progname, data: {}) return true if @logdev.nil? || severity < @level data ||= {} if .is_a?(::Exception) data[:err] = else data[:msg] = end @logdev.write( (to_label(severity), Time.now, progname, data) ) true end |