Class: Rex::Ui::Text::Output::Tee
- Inherits:
-
Rex::Ui::Text::Output
- Object
- Output
- Rex::Ui::Text::Output
- Rex::Ui::Text::Output::Tee
- Defined in:
- lib/rex/ui/text/output/tee.rb
Overview
This class implements output against a file and stdout
Constant Summary
Constants included from Color
Instance Attribute Summary collapse
-
#fd ⇒ Object
Returns the value of attribute fd.
Attributes inherited from Rex::Ui::Text::Output
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(path) ⇒ Tee
constructor
A new instance of Tee.
-
#print_raw(msg = '') ⇒ Object
Prints the supplied message to file output.
- #supports_color? ⇒ Boolean
Methods inherited from Rex::Ui::Text::Output
#auto_color, #disable_color, #enable_color, #print, #print_debug, #print_error, #print_good, #print_line, #print_status, #print_warning, #reset, #update_prompt
Methods included from Color
#ansi, #colorize, #do_colorize, #reset_color, #substitute_colors
Methods inherited from Output
#flush, #print, #print_debug, #print_error, #print_good, #print_line, #print_status, #print_warning, #prompting, #prompting?
Constructor Details
#initialize(path) ⇒ Tee
Returns a new instance of Tee.
17 18 19 20 |
# File 'lib/rex/ui/text/output/tee.rb', line 17 def initialize(path) self.fd = ::File.open(path, "ab") super() end |
Instance Attribute Details
#fd ⇒ Object
Returns the value of attribute fd.
15 16 17 |
# File 'lib/rex/ui/text/output/tee.rb', line 15 def fd @fd end |
Instance Method Details
#close ⇒ Object
47 48 49 50 |
# File 'lib/rex/ui/text/output/tee.rb', line 47 def close self.fd.close if self.fd self.fd = nil end |
#print_raw(msg = '') ⇒ Object
Prints the supplied message to file output.
37 38 39 40 41 42 43 44 45 |
# File 'lib/rex/ui/text/output/tee.rb', line 37 def print_raw(msg = '') $stdout.print(msg) $stdout.flush return if not self.fd self.fd.write(msg) self.fd.flush msg end |
#supports_color? ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rex/ui/text/output/tee.rb', line 22 def supports_color? case config[:color] when true return true when false return false else # auto term = Rex::Compat.getenv('TERM') return (term and term.match(/(?:vt10[03]|xterm(?:-color)?|linux|screen|rxvt)/i) != nil) end end |