Class: Bole::Manager
- Inherits:
-
Logger
- Object
- Logger
- Bole::Manager
- Defined in:
- lib/bole/manager.rb
Overview
Logger main class
Constant Summary collapse
- PROGNAME =
'Bole'
- LOG_LEVELS =
{ none: Logger::UNKNOWN, fatal: Logger::FATAL, error: Logger::ERROR, warn: Logger::WARN, info: Logger::INFO, debug: Logger::DEBUG }.freeze
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
Instance Method Summary collapse
- #add(severity, message = nil, progname = nil) ⇒ Object
-
#initialize(logdev = STDOUT, shift_age = 0, shift_size = 1_048_576, level: LOG_LEVELS[:debug], progname: nil, formatter: nil, datetime_format: nil, shift_period_suffix: '%Y%m%d', config: nil) ⇒ Manager
constructor
Initializer arguments: The first set of arguments are the exact same as the Ruby Standard Library’s logger class.
- #level=(severity) ⇒ Object
- #logger ⇒ Object
- #logger=(new_logdev) ⇒ Object
Constructor Details
#initialize(logdev = STDOUT, shift_age = 0, shift_size = 1_048_576, level: LOG_LEVELS[:debug], progname: nil, formatter: nil, datetime_format: nil, shift_period_suffix: '%Y%m%d', config: nil) ⇒ Manager
Initializer arguments: The first set of arguments are the exact same as the Ruby Standard Library’s logger class. The goal of this class is to extend the functionality to make the class easier to work with so we are adding an extra argument to take an additional option:
config: ‘/path/to/bole.yml’
This is an optional argument that is the path to the Konfigyu config YAML file so defaults can easily be persisted as part of your application’s configuration. Optionally you can specify an existing Konfigyu object in Bole::Manager.config
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bole/manager.rb', line 35 def initialize(logdev = STDOUT, shift_age = 0, shift_size = 1_048_576, level: LOG_LEVELS[:debug], progname: nil, formatter: nil, datetime_format: nil, shift_period_suffix: '%Y%m%d', config: nil) initialize_configuration(config) @shift_age = shift_age @shift_size = shift_size @shift_period_suffix = '%Y%m%d' super(logdev, shift_age, shift_size, level: level, progname: progname, formatter: formatter, datetime_format: datetime_format, shift_period_suffix: shift_period_suffix) initialize_logger end |
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
20 21 22 |
# File 'lib/bole/manager.rb', line 20 def config @config end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
6 7 8 |
# File 'lib/bole/manager.rb', line 6 def enabled @enabled end |
Instance Method Details
#add(severity, message = nil, progname = nil) ⇒ Object
75 76 77 |
# File 'lib/bole/manager.rb', line 75 def add(severity, = nil, progname = nil) super(severity, , progname) if @enabled end |
#level=(severity) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/bole/manager.rb', line 65 def level=(severity) if severity.to_s.casecmp('none').zero? @level = Logger::UNKNOWN @enabled = false else @enabled = true super(severity) end end |
#logger ⇒ Object
52 53 54 |
# File 'lib/bole/manager.rb', line 52 def logger @logdev end |
#logger=(new_logdev) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/bole/manager.rb', line 56 def logger=(new_logdev) @logdev = Logger::LogDevice.new( new_logdev, shift_age: @shift_age, shift_size: @shift_size, shift_period_suffix: @shift_period_suffix ) end |