Class: Monad::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/monad/logger.rb

Class Method Summary collapse

Class Method Details

.error(topic, message) ⇒ Object

Public: Print a monad error message to stderr

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

Returns nothing



31
32
33
# File 'lib/monad/logger.rb', line 31

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



50
51
52
# File 'lib/monad/logger.rb', line 50

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

.info(topic, message) ⇒ Object

Public: Print a monad message to stdout

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

Returns nothing



11
12
13
# File 'lib/monad/logger.rb', line 11

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

.message(topic, message) ⇒ Object

Public: Build a Monad topic method

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

Returns the formatted message



41
42
43
# File 'lib/monad/logger.rb', line 41

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

.warn(topic, message) ⇒ Object

Public: Print a monad message to stderr

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

Returns nothing



21
22
23
# File 'lib/monad/logger.rb', line 21

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