Module: Webgen::Loggable
- Included in:
- ContentProcessor::Blocks, ContentProcessor::Head, ContentProcessor::Tags, Node, SourceHandler::Base, SourceHandler::Main, SourceHandler::Template, Tag::Base, Website
- Defined in:
- lib/webgen/loggable.rb
Overview
This module should be included in all classes that need a logging facility.
Instance Method Summary collapse
-
#log(sev_level, &block) ⇒ Object
Log the result of the
block
using the log levellog_level
. -
#puts(*args) ⇒ Object
Shortcut for writing a line to the normal log output.
Instance Method Details
#log(sev_level, &block) ⇒ Object
Log the result of the block
using the log level log_level
.
11 12 13 14 15 16 |
# File 'lib/webgen/loggable.rb', line 11 def log(sev_level, &block) source = (self.kind_of?(Class) ? self.name : self.class.name) + '#' + caller[0][%r"`.*"][1..-2] if WebsiteAccess.website && WebsiteAccess.website.logger && (!WebsiteAccess.website.config['logger.mask'] || source =~ WebsiteAccess.website.config['logger.mask']) WebsiteAccess.website.logger.send(sev_level, source, &block) end end |
#puts(*args) ⇒ Object
Shortcut for writing a line to the normal log output.
19 20 21 |
# File 'lib/webgen/loggable.rb', line 19 def puts(*args) (args.last == :verbose ? log(:verbose) { args[0..-2].join } : log(:stdout) { args.join }) end |