Module: Moft::Logger
- Defined in:
- lib/moft/logger.rb
Class Method Summary collapse
-
.error(topic, message) ⇒ Object
Public: Print a moft error message to stderr.
-
.formatted_topic(topic) ⇒ Object
Public: Format the topic.
-
.info(topic, message) ⇒ Object
Public: Print a moft message to stdout.
-
.message(topic, message) ⇒ Object
Public: Build a Moft topic method.
-
.warn(topic, message) ⇒ Object
Public: Print a moft message to stderr.
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, ) $stderr.puts (topic, ).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, ) $stdout.puts (topic, ) 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.(topic, ) formatted_topic(topic) + .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, ) $stderr.puts (topic, ).yellow end |