Module: Pentest::Logger
- Defined in:
- lib/pentest/logger.rb
Constant Summary collapse
- PADDING =
' ' * 10
- MAX_WIDTH =
60
- @@progress_counter =
0
Class Method Summary collapse
- .debug(text, timestamp: true) ⇒ Object
- .end_progress ⇒ Object
- .error(text, timestamp: true) ⇒ Object
- .info(text, timestamp: true) ⇒ Object
- .print_seperator ⇒ Object
- .put_progress(char) ⇒ Object
- .start_progress ⇒ Object
- .time(enabled = true) ⇒ Object
- .warn(text, timestamp: true) ⇒ Object
Class Method Details
.debug(text, timestamp: true) ⇒ Object
12 13 14 |
# File 'lib/pentest/logger.rb', line 12 def debug(text, timestamp: true) puts "#{time()} #{Term::ANSIColor.blue(text)}" end |
.end_progress ⇒ Object
50 51 52 |
# File 'lib/pentest/logger.rb', line 50 def end_progress print "\n" end |
.error(text, timestamp: true) ⇒ Object
24 25 26 |
# File 'lib/pentest/logger.rb', line 24 def error(text, timestamp: true) puts "#{time()} #{Term::ANSIColor.red(text)}" end |
.info(text, timestamp: true) ⇒ Object
16 17 18 |
# File 'lib/pentest/logger.rb', line 16 def info(text, timestamp: true) puts "#{time()} #{Term::ANSIColor.green(text)}" end |
.print_seperator ⇒ Object
54 55 56 |
# File 'lib/pentest/logger.rb', line 54 def print_seperator print "\n" end |
.put_progress(char) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pentest/logger.rb', line 39 def put_progress(char) if @@progress_counter + char.size > MAX_WIDTH print "\n" print PADDING + ' ' @@progress_counter = 0 end print char @@progress_counter += char.size end |
.start_progress ⇒ Object
34 35 36 37 |
# File 'lib/pentest/logger.rb', line 34 def start_progress print PADDING + ' ' @@progress_counter = 0 end |
.time(enabled = true) ⇒ Object
28 29 30 31 32 |
# File 'lib/pentest/logger.rb', line 28 def time(enabled = true) return PADDING unless enabled now = Time.now "[#{now.strftime("%H:%M:%S")}]" end |
.warn(text, timestamp: true) ⇒ Object
20 21 22 |
# File 'lib/pentest/logger.rb', line 20 def warn(text, timestamp: true) puts "#{time()} #{Term::ANSIColor.yellow(text)}" end |