Sha256: 876ec6d90b136f9b967feb4b07e3b03f0c83517b89e73c043d2d0b8b09b442e3
Contents?: true
Size: 1.14 KB
Versions: 18
Compression:
Stored size: 1.14 KB
Contents
# -*- encoding: utf-8 -*- require 'logger' module Webgen # This custom logger class needs to be used (either directly or via a sub-class) for the # Webgen::Website logging object. # # It provides the following, additional functionality over the stdlib Logger class: # # * If a logging message is an Array and #verbose is +false+, only the first item of the array is # output. If #verbose is +true+, the the items of the array are joined using a line break and # output. # # * You can add verbose info messages using the #vinfo method. # class Logger < ::Logger # Whether verbose log message should be output. Either +true+ or +false+ (default: +false+). attr_accessor :verbose def initialize(*args, &block) #:nodoc: super @verbose = false end def format_message(severity, datetime, progname, msg) #:nodoc: first, *rest = *msg msg = (@verbose ? [first, *rest].join("\n") : first) super(severity, datetime, progname, msg) end # Log a verbose info message. def vinfo(progname = nil, &block) add(::Logger::INFO, nil, progname, &block) if @verbose end end end
Version data entries
18 entries across 18 versions & 1 rubygems