class Bauxite::Loggers::XtermLogger

XTerm logger.

This logger outputs colorized lines using xterm (VT100/2) escape sequences.

XTerm logger options include:

nc, color

If set to ‘no’, prints text without using colors. Note that positional escape sequences will still be used to show progress. To disable escape sequences completely, consider using the Bauxite::Loggers::TerminalLogger logger instead.

Protected Instance Methods

_fmt(color, text, size = 0) click to toggle source
Calls superclass method Bauxite::Loggers::TerminalLogger#_fmt
# File lib/bauxite/loggers/xterm.rb, line 60
def _fmt(color, text, size = 0)
        text = super(color, text, size)
        if @options[:nc] or @options[:color] == 'no'
                text
        else
                "\033[#{COLORS[color]}m#{text}\033[0m"
        end
end
_restore_cursor() click to toggle source
# File lib/bauxite/loggers/xterm.rb, line 74
def _restore_cursor
        print "\033[u"
        true
end
_save_cursor() click to toggle source
# File lib/bauxite/loggers/xterm.rb, line 69
def _save_cursor
        print "\033[s"
        true
end
_screen_width() click to toggle source
Calls superclass method Bauxite::Loggers::TerminalLogger#_screen_width
# File lib/bauxite/loggers/xterm.rb, line 84
def _screen_width
        if RbConfig::CONFIG['host_os'] =~
/(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
                (_dynamic_width_stty.nonzero? || _dynamic_width_tput)
        else
                super
        end
rescue Exception => e
        super
end

Private Instance Methods

_dynamic_width_stty() click to toggle source
# File lib/bauxite/loggers/xterm.rb, line 96
def _dynamic_width_stty
  %x{stty size 2>/dev/null}.split[1].to_i
end
_dynamic_width_tput() click to toggle source
# File lib/bauxite/loggers/xterm.rb, line 99
def _dynamic_width_tput
  %x{tput cols 2>/dev/null}.to_i
end