Module: ScaBox::Printer
- Included in:
- Scanner
- Defined in:
- lib/scabox_sdk/printer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #coloring(flag = true) ⇒ Object
- #print_debug(s, level = 0) ⇒ Object
- #print_error(s, level = 0) ⇒ Object
- #print_normal(s, level = 0) ⇒ Object
- #print_success(s, level = 0) ⇒ Object
- #print_title(s, level = 0) ⇒ Object
- #print_with_label(s, label, level = 0) ⇒ Object
- #suppress_output? ⇒ Boolean
Class Method Details
.included(base) ⇒ Object
80 81 82 |
# File 'lib/scabox_sdk/printer.rb', line 80 def self.included(base) #base.instance_variable_set(:@color, true) end |
Instance Method Details
#coloring(flag = true) ⇒ Object
7 8 9 |
# File 'lib/scabox_sdk/printer.rb', line 7 def coloring(flag = true) @color = flag end |
#print_debug(s, level = 0) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/scabox_sdk/printer.rb', line 67 def print_debug(s, level = 0) return if suppress_output? pad = " " * (level * 4) now = DateTime.now.strftime('%d/%m/%Y %H:%M:%S.%3N') out_s = "#{pad}DEBUG|#{now}| #{s}" if @color puts out_s.bold.yellow else puts out_s end @logger.debug(out_s) if instance_variable_defined?("@logger") end |
#print_error(s, level = 0) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/scabox_sdk/printer.rb', line 47 def print_error(s, level = 0) return if suppress_output? pad = " " * (level * 4) out_s = "#{pad}[ ERROR ] #{s}" if @color puts out_s.bold.red else puts out_s end @logger.error(out_s) if instance_variable_defined?("@logger") end |
#print_normal(s, level = 0) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/scabox_sdk/printer.rb', line 27 def print_normal(s, level = 0) return if suppress_output? pad = " " * (level * 4) out_s = "#{pad}#{s}" puts out_s @logger.info(out_s) if instance_variable_defined?("@logger") end |
#print_success(s, level = 0) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/scabox_sdk/printer.rb', line 35 def print_success(s, level = 0) return if suppress_output? pad = " " * (level * 4) out_s = "#{pad}[SUCCESS] #{s}" if @color puts out_s.bold.green else puts out_s end @logger.info(out_s) if instance_variable_defined?("@logger") end |
#print_title(s, level = 0) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/scabox_sdk/printer.rb', line 15 def print_title(s, level = 0) return if suppress_output? pad = " " * (level * 4) out_s = "#{pad}[*] #{s}" if @color puts out_s.bold.blue else puts out_s end @logger.info(out_s) if instance_variable_defined?("@logger") end |
#print_with_label(s, label, level = 0) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/scabox_sdk/printer.rb', line 59 def print_with_label(s, label, level = 0) return if suppress_output? pad = " " * (level * 4) out_s = "#{pad}[#{label}] #{s}" puts out_s @logger.info(out_s) if instance_variable_defined?("@logger") end |
#suppress_output? ⇒ Boolean
11 12 13 |
# File 'lib/scabox_sdk/printer.rb', line 11 def suppress_output? @opts.output_stdout end |