Sha256: 87a66fcb02e9e0d980ce7c6529e5dec3df76c4ffa3ad84262a3c9a291d9dacf3

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

# TITLE:
#
#   Logger
#
# SUMMARY:
#
#   Extended variation of Ruby's standard Logger library.
#
# COPYRIGHT:
#
#   Copyright (c) 2005 George Moschovitis
#
# LICENSE:
#
#   Ruby License
#
#   This module is free software. You may use, modify, and/or redistribute this
#   software under the same terms as Ruby.
#
#   This program is distributed in the hope that it will be useful, but WITHOUT
#   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
#   FOR A PARTICULAR PURPOSE.
#
# AUTHORS:
#
#   - George Moschovitis


require 'logger'

# = Logger
#
# Extended variation of Ruby's standard Logger library.
#
class Logger

  private

  # Dictate the way in which this logger should format the messages
  # it displays. This method requires a block. The block should return
  # formatted strings given severity, timestamp, msg, progname.
  #
  # Useless example:
  #
  # logger = Logger.new
  # logger.format do |severity, timestamp, msg, progname|
  #   "#{progname}@#{timestamp} - #{severity}::#{msg}"
  # end
  #
  def format(&format_proc)
    raise 'block expected' unless format_proc
    @format_proc = format_proc
  end

  # hackish use of *args, give me some love
  def format_message(*args)
    @format_proc ? @format_proc.call(*args) : super(*args)
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
facets-2.0.0 lib/more/facets/logger.rb
facets-2.0.1 lib/more/facets/logger.rb
facets-2.0.2 lib/more/facets/logger.rb
facets-2.1.0 lib/more/facets/logger.rb
facets-2.0.3 lib/more/facets/logger.rb
facets-2.0.4 lib/more/facets/logger.rb
facets-2.0.5 lib/more/facets/logger.rb