Class: Backy::Logger

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

Class Method Summary collapse

Class Method Details

.error(message) ⇒ Object



25
26
27
# File 'lib/backy/logger.rb', line 25

def self.error(message)
  log(message, :red)
end

.info(message) ⇒ Object



17
18
19
# File 'lib/backy/logger.rb', line 17

def self.info(message)
  log(message, :blue)
end

.log(message, color = nil) ⇒ Object

Logs a message with the specified color using Thor’s shell



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

def self.log(message, color = nil)
  @log_messages << message
  say("[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] #{message}\n", color)
end

.log_messagesObject



33
34
35
# File 'lib/backy/logger.rb', line 33

def self.log_messages
  @log_messages
end

.say(message, color = nil) ⇒ Object



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

def self.say(message, color = nil)
  thor_shell.say(message, color)
end

.success(message) ⇒ Object



13
14
15
# File 'lib/backy/logger.rb', line 13

def self.success(message)
  log(message, :green)
end

.warn(message) ⇒ Object



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

def self.warn(message)
  log(message, :yellow)
end