Class: Sensible::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/sensible/log.rb

Class Method Summary collapse

Class Method Details

.clear_lineObject



75
76
77
# File 'lib/sensible/log.rb', line 75

def self.clear_line()
  print "\r\e[K"
end

.danger(message, indent = 0, use_print: false) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/sensible/log.rb', line 42

def self.danger(message, indent = 0, use_print: false)
  spaceIndent = ""
  indent.times { |i| spaceIndent << " " }
  
  if use_print
    print "#{spaceIndent}#{$pastel.red("✘")} #{message}"
  else      
    puts "#{spaceIndent}#{$pastel.red("✘")} #{message}"
  end      
end

.error(message, indent = 0, use_print: false) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/sensible/log.rb', line 53

def self.error(message, indent = 0, use_print: false)
  spaceIndent = ""
  indent.times { |i| spaceIndent << " " }

  full_message = "#{spaceIndent}#{$pastel.on_red.black(" ERROR ")} #{message}"
  
  if use_print
    print full_message
  else      
    puts full_message
  end      
end

.flushObject



79
80
81
# File 'lib/sensible/log.rb', line 79

def self.flush
  $stdout.flush
end

.info(message, indent = 0, use_print: false) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/sensible/log.rb', line 31

def self.info(message, indent = 0, use_print: false)
  spaceIndent = ""
  indent.times { |i| spaceIndent << " " }
 
  if use_print
    print "#{spaceIndent}#{$pastel.blue("i")} #{message}"
  else      
    puts "#{spaceIndent}#{$pastel.blue("i")} #{message}"
  end
end

.log(message, indent = 0, use_print: false) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/sensible/log.rb', line 9

def self.log(message, indent = 0, use_print: false)
  spaceIndent = ""
  indent.times { |i| spaceIndent << " " }

  if use_print
    print "#{spaceIndent}#{message}"
  else      
    puts "#{spaceIndent}#{message}"
  end
end

.success(message, indent = 0, use_print: false) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/sensible/log.rb', line 20

def self.success(message, indent = 0, use_print: false)
  spaceIndent = ""
  indent.times { |i| spaceIndent << " " }

  if use_print
    print "#{spaceIndent}#{$pastel.green("✔")} #{message}"
  else      
    puts "#{spaceIndent}#{$pastel.green("✔")} #{message}"
  end
end

.yes?(message, indent = 0) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
69
70
71
72
73
# File 'lib/sensible/log.rb', line 66

def self.yes?(message, indent = 0)
  prompt = TTY::Prompt.new

  spaceIndent = ""
  indent.times { |i| spaceIndent << " " }

  prompt.yes?("#{spaceIndent}#{message}")
end