Sha256: 99fc449a2ba5a133aa578fd99e11667e7d1ba3f632eea8eb94864e74de8d1b62

Contents?: true

Size: 829 Bytes

Versions: 15

Compression:

Stored size: 829 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'webgen/websiteaccess'

module Webgen

  # This module should be included in all classes that need a logging facility.
  module Loggable

    # Log the result of the +block+ using the log level +log_level+.
    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

    # Shortcut for writing a line to the normal log output.
    def puts(*args)
      (args.last == :verbose ? log(:verbose) { args[0..-2].join } : log(:stdout) { args.join })
    end

  end

end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
gettalong-webgen-0.5.7.20090227 lib/webgen/loggable.rb
gettalong-webgen-0.5.8.20090507 lib/webgen/loggable.rb
gettalong-webgen-0.5.9.20090620 lib/webgen/loggable.rb
gettalong-webgen-0.5.9.20090626 lib/webgen/loggable.rb
thewoolleyman-webgen-0.5.8.20090419 lib/webgen/loggable.rb
webgen-0.5.17 lib/webgen/loggable.rb
webgen-0.5.15 lib/webgen/loggable.rb
webgen-0.5.14 lib/webgen/loggable.rb
webgen-0.5.13 lib/webgen/loggable.rb
webgen-0.5.12 lib/webgen/loggable.rb
webgen-0.5.11 lib/webgen/loggable.rb
webgen-0.5.10 lib/webgen/loggable.rb
webgen-0.5.9 lib/webgen/loggable.rb
webgen-0.5.7 lib/webgen/loggable.rb
webgen-0.5.8 lib/webgen/loggable.rb