Sha256: 442a109320890c4d5db2c2eb9e11b0053ee7d484c240d93a7a4ff576bca28f6e

Contents?: true

Size: 489 Bytes

Versions: 11

Compression:

Stored size: 489 Bytes

Contents

require 'logger'

#  Logger Class extensions
class Logger

  # Creates a custom Logger level based on the passed
  # tag.
  # @param [String] tag The Logger level to create
  # @return [void]
  def self.custom_level(tag)
    SEV_LABEL << tag 
    idx = SEV_LABEL.size - 1 

    define_method(tag.downcase.gsub(/\W+/, '_').to_sym) do |progname, &block|
      add(idx, nil, progname, &block)
    end 
  end 
  
  custom_level('PROMPT')
  custom_level('SECTION')
  custom_level('SUCCESS')
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cliutils-1.2.3 lib/cliutils/ext/Logger+Extensions.rb
cliutils-1.2.2 lib/cliutils/ext/Logger+Extensions.rb
cliutils-1.2.1 lib/cliutils/ext/Logger+Extensions.rb
cliutils-1.2.0 lib/cliutils/ext/Logger+Extensions.rb
cliutils-1.1.1 lib/cliutils/ext/Logger+Extensions.rb
cliutils-1.1.0 lib/cliutils/ext/Logger+Extensions.rb
cliutils-1.0.7 lib/cliutils/ext/Logger+Extensions.rb
cliutils-1.0.6 lib/cliutils/ext/Logger+Extensions.rb
cliutils-1.0.5 lib/cliutils/ext/Logger+Extensions.rb
cliutils-1.0.4 lib/cliutils/ext/Logger+Extensions.rb
cliutils-1.0.3 lib/cliutils/ext/Logger+Extensions.rb