Class: Ghaki::Logger::Base
- Includes:
- Liner
- Defined in:
- lib/ghaki/logger/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#major ⇒ Object
Returns the value of attribute major.
-
#minor ⇒ Object
Returns the value of attribute minor.
Attributes included from Liner
Attributes included from CoreExt::Logger
Instance Method Summary collapse
-
#dup ⇒ Object
Create similar logger that uses the same log device.
-
#initialize(opts = {}) ⇒ Base
constructor
Constructor options:.
-
#level=(val) ⇒ Object
Set logging level.
Methods included from Liner
#box, #fatal_dump, #liner, #puts
Methods included from CoreExt::Logger
#bounce, #re_open, #re_stderr, #re_stdout, #re_stds, #rotate
Constructor Details
#initialize(opts = {}) ⇒ Base
Constructor options:
box_char
-
Character used to make line separators in the logs.
box_size
-
Line length used for separators in the logs.
datetime_format
-
Date/time format used for logging.
file_handle
-
Open file handle to log to.
file_name
-
Name of file to open for logging.
level
-
Verbosity of logging.
shift_age
- Shift age for logs, see ::Logger
-
for details.
shift_size
-
Shift size for logs, see ::Logger for details.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ghaki/logger/base.rb', line 34 def initialize opts={} setup_liner opts @major = Ghaki::Logger::Wrapper::Major.new({ :logger => self, :box_char => opts[:box_char], :box_size => opts[:box_size], }) @minor = Ghaki::Logger::Wrapper::Minor.new({ :logger => self, }) if opts[:log_device].nil? super( *([ opts[:file_handle] || opts[:file_name] || $stderr, opts[:shift_age], opts[:shift_size] ].compact) ) else super(nil) self.logdev = opts[:log_device] end self.level = opts[:level] || DEF_LEVEL self.datetime_format = opts[:datetime_format] || DEF_DATETIME_FORMAT end |
Instance Attribute Details
#major ⇒ Object
Returns the value of attribute major.
15 16 17 |
# File 'lib/ghaki/logger/base.rb', line 15 def major @major end |
#minor ⇒ Object
Returns the value of attribute minor.
15 16 17 |
# File 'lib/ghaki/logger/base.rb', line 15 def minor @minor end |
Instance Method Details
#dup ⇒ Object
Create similar logger that uses the same log device.
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ghaki/logger/base.rb', line 73 def dup Ghaki::Logger::Base.new({ :log_device => self.logdev, :level => self.level, :datetime_format => self.datetime_format, :shift_age => self.shift_age, :shift_size => self.shift_size, :box_char => self.box_char, :box_size => self.box_size, }) end |
#level=(val) ⇒ Object
Set logging level. Assert on invalid level.
65 66 67 68 69 |
# File 'lib/ghaki/logger/base.rb', line 65 def level= val val = SEVERITY_LOOKUP[val] raise ArgumentError, "Invalid log level: #{val}" if val.nil? super(val) end |