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-2.2.6 lib/cliutils/ext/logger_extensions.rb
cliutils-2.2.5 lib/cliutils/ext/logger_extensions.rb
cliutils-2.2.4 lib/cliutils/ext/logger_extensions.rb
cliutils-2.2.3 lib/cliutils/ext/logger_extensions.rb
cliutils-2.2.2 lib/cliutils/ext/logger_extensions.rb
cliutils-2.2.1 lib/cliutils/ext/logger_extensions.rb
cliutils-2.2.0 lib/cliutils/ext/logger_extensions.rb
cliutils-2.1.4 lib/cliutils/ext/logger_extensions.rb
cliutils-2.1.3 lib/cliutils/ext/logger_extensions.rb
cliutils-2.1.2 lib/cliutils/ext/logger_extensions.rb
cliutils-2.1.1 lib/cliutils/ext/logger_extensions.rb
cliutils-2.1.0 lib/cliutils/ext/logger_extensions.rb
cliutils-2.0.3 lib/cliutils/ext/logger_extensions.rb
cliutils-2.0.2 lib/cliutils/ext/logger_extensions.rb
cliutils-2.0.1 lib/cliutils/ext/logger_extensions.rb
cliutils-2.0.0 lib/cliutils/ext/logger_extensions.rb
cliutils-1.4.2 lib/cliutils/ext/logger_extensions.rb
cliutils-1.4.1 lib/cliutils/ext/logger_extensions.rb
cliutils-1.4.0 lib/cliutils/ext/logger_extensions.rb
cliutils-1.3.1 lib/cliutils/ext/logger_extensions.rb