Module: Moft::Logger

Defined in:
lib/moft/logger.rb

Class Method Summary collapse

Class Method Details

.error(topic, message) ⇒ Object

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



29
30
31
# File 'lib/moft/logger.rb', line 29

def self.error(topic, message)
  $stderr.puts message(topic, message).red
end

.formatted_topic(topic) ⇒ Object

Public: Format the topic

topic - the topic of the message, e.g. “Configuration file”, “Deprecation”, etc.

Returns the formatted topic statement



48
49
50
# File 'lib/moft/logger.rb', line 48

def self.formatted_topic(topic)
  "#{topic} ".rjust(20)
end

.info(topic, message) ⇒ Object

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



9
10
11
# File 'lib/moft/logger.rb', line 9

def self.info(topic, message)
  $stdout.puts message(topic, message)
end

.message(topic, message) ⇒ Object

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



39
40
41
# File 'lib/moft/logger.rb', line 39

def self.message(topic, message)
   formatted_topic(topic) + message.gsub(/\s+/, ' ')
end

.warn(topic, message) ⇒ Object

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



19
20
21
# File 'lib/moft/logger.rb', line 19

def self.warn(topic, message)
  $stderr.puts message(topic, message).yellow
end