Sha256: 4148f658f17ed74254af4f05ab3142b915c36b490076b792870b482beabaa726

Contents?: true

Size: 1.44 KB

Versions: 7

Compression:

Stored size: 1.44 KB

Contents

module Moft
  module Logger
    # Public: Print a moft message to stdout
    #
    # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
    # message - the message detail
    #
    # Returns nothing
    def self.info(topic, message)
      $stdout.puts message(topic, message)
    end

    # Public: Print a moft message to stderr
    #
    # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
    # message - the message detail
    #
    # Returns nothing
    def self.warn(topic, message)
      $stderr.puts message(topic, message).yellow
    end

    # Public: Print a moft error message to stderr
    #
    # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
    # message - the message detail
    #
    # Returns nothing
    def self.error(topic, message)
      $stderr.puts message(topic, message).red
    end

    # Public: Build a Moft topic method
    #
    # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
    # message - the message detail
    #
    # Returns the formatted message
    def self.message(topic, message)
       formatted_topic(topic) + message.gsub(/\s+/, ' ')
    end

    # Public: Format the topic
    #
    # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
    #
    # Returns the formatted topic statement
    def self.formatted_topic(topic)
      "#{topic} ".rjust(20)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
moft-1.0.5 lib/moft/logger.rb
moft-1.0.4 lib/moft/logger.rb
moft-1.0.3 lib/moft/logger.rb
moft-1.0.2.1 lib/moft/logger.rb
moft-1.0.2 lib/moft/logger.rb
moft-1.0.1 lib/moft/logger.rb
moft-1.0.0 lib/moft/logger.rb