Class: PluginMetaLogger
- Inherits:
-
Object
- Object
- PluginMetaLogger
- Includes:
- Singleton
- Defined in:
- lib/jekyll_plugin_meta_logger.rb
Overview
Makes a meta-logger instance (a singleton) with level set by ‘site.config`. Saves `site.config` for later use when creating plugin loggers; these loggers each have their own log levels.
For example, if the plugin’s progname has value ‘MyPlugin` then an entry called `plugin_loggers.MyPlugin` will be read from `config`, if present. If no such entry is found then the meta-logger log_level is set to `:info`. If you want to see messages that indicate the loggers and log levels as they are created, set the log level for `PluginMetaLogger` to `debug` in `_config.yml`
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #debug(&block) ⇒ Object
- #error(&block) ⇒ Object
- #info(&block) ⇒ Object
-
#initialize ⇒ PluginMetaLogger
constructor
A new instance of PluginMetaLogger.
- #level_as_sym ⇒ Object
- #new_logger(klass, config = nil, stream_name = $stdout) ⇒ Object
- #warn(&block) ⇒ Object
Constructor Details
#initialize ⇒ PluginMetaLogger
Returns a new instance of PluginMetaLogger.
35 36 37 38 39 |
# File 'lib/jekyll_plugin_meta_logger.rb', line 35 def initialize super @config = nil @logger = new_logger(self) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
33 34 35 |
# File 'lib/jekyll_plugin_meta_logger.rb', line 33 def config @config end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
33 34 35 |
# File 'lib/jekyll_plugin_meta_logger.rb', line 33 def logger @logger end |
Instance Method Details
#debug(&block) ⇒ Object
45 46 47 |
# File 'lib/jekyll_plugin_meta_logger.rb', line 45 def debug(&block) @logger.debug(self) { yield block } end |
#error(&block) ⇒ Object
57 58 59 |
# File 'lib/jekyll_plugin_meta_logger.rb', line 57 def error(&block) @logger.error(self) { yield block } end |
#info(&block) ⇒ Object
41 42 43 |
# File 'lib/jekyll_plugin_meta_logger.rb', line 41 def info(&block) @logger.info(self) { yield block } end |
#level_as_sym ⇒ Object
49 50 51 |
# File 'lib/jekyll_plugin_meta_logger.rb', line 49 def level_as_sym @logger.level_as_sym end |
#new_logger(klass, config = nil, stream_name = $stdout) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/jekyll_plugin_meta_logger.rb', line 61 def new_logger(klass, config = nil, stream_name = $stdout) @config ||= config if @config.nil? puts { 'Error: PluginMetaLogger has not been initialized with site.config.'.red } PluginLogger.new(klass, {}, stream_name) else PluginLogger.new(klass, @config, stream_name) end end |
#warn(&block) ⇒ Object
53 54 55 |
# File 'lib/jekyll_plugin_meta_logger.rb', line 53 def warn(&block) @logger.warn(self) { yield block } end |