Sha256: 2955469d1aa8b217a6161541d05ff6203e8b552ae18e389d9d87013966683ec2

Contents?: true

Size: 483 Bytes

Versions: 27

Compression:

Stored size: 483 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

27 entries across 27 versions & 1 rubygems

Version Path
cliutils-1.3.0 lib/cliutils/ext/logger_extensions.rb
cliutils-1.2.9 lib/cliutils/ext/logger_extensions.rb
cliutils-1.2.8 lib/cliutils/ext/logger_extensions.rb
cliutils-1.2.7 lib/cliutils/ext/logger_extensions.rb
cliutils-1.2.6 lib/cliutils/ext/logger_extensions.rb
cliutils-1.2.5 lib/cliutils/ext/logger_extensions.rb
cliutils-1.2.4 lib/cliutils/ext/logger_extensions.rb