Subversion Info

Rev
430
Last Checked In
2008-01-18 20:36:29 (12 weeks ago)
Checked in by
deveiant

Methods

Class Index

Quicksearch

Arrow::Logger::ColorOutputter

Output logging messages in ANSI colors according to their level

Constants

SVNRev
SVN Revision
SVNId
SVN Id
AnsiAttributes
Set some ANSI escape code constants (Shamelessly stolen from Perl‘s Term::ANSIColor by Russ Allbery <rra@stanford.edu> and Zenin <zenin@best.com>
DEFAULT_COLOR_SCHEME
Default color map: :level => %w{color scheme}
DEFAULT_DESCRIPTION
Default decription used when creating instances
DEFAULT_FORMAT
The default logging output format

Attributes

color_scheme[R]
The color scheme hash for this logger

Public Instance Methods

write( time, level, name, frame, msg ) click to toggle source

Write the given level, name, frame, and msg to the logfile.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/logger/coloroutputter.rb, line 98
 98:     def write( time, level, name, frame, msg )
 99:         colors = @color_scheme[level]
100:         super do |msg|
101:             color_msg = colorize( msg, colors )
102:             @io.puts( color_msg )
103:         end
104:     end

Protected Instance Methods

initialize( uri, description=DEFAULT_DESCRIPTION, format=DEFAULT_FORMAT ) click to toggle source

Override the default to add color scheme instance variable

    # File /Users/ged/source/ruby/Arrow/lib/arrow/logger/coloroutputter.rb, line 83
83:     def initialize( uri, description=DEFAULT_DESCRIPTION, format=DEFAULT_FORMAT ) # :notnew:
84:         super
85:         @color_scheme = DEFAULT_COLOR_SCHEME.dup
86:     end

secsequence

--- SEC00066

seccomment

--- ""

attributes

--- 
- name: color_scheme
  rw: R
  a_desc: |+
    
    The color scheme hash for this logger
    

method_list

--- 
- methods: 
  - visibility: public
    aref: M000200
    name: write
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/logger/coloroutputter.rb, line 98</span>\n 98:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">write</span>( <span class=\"ruby-identifier\">time</span>, <span class=\"ruby-identifier\">level</span>, <span class=\"ruby-identifier\">name</span>, <span class=\"ruby-identifier\">frame</span>, <span class=\"ruby-identifier\">msg</span> )\n 99:         <span class=\"ruby-identifier\">colors</span> = <span class=\"ruby-ivar\">@color_scheme</span>[<span class=\"ruby-identifier\">level</span>]\n\
      100:         <span class=\"ruby-keyword kw\">super</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">msg</span><span class=\"ruby-operator\">|</span>\n\
      101:             <span class=\"ruby-identifier\">color_msg</span> = <span class=\"ruby-identifier\">colorize</span>( <span class=\"ruby-identifier\">msg</span>, <span class=\"ruby-identifier\">colors</span> )\n\
      102:             <span class=\"ruby-ivar\">@io</span>.<span class=\"ruby-identifier\">puts</span>( <span class=\"ruby-identifier\">color_msg</span> )\n\
      103:         <span class=\"ruby-keyword kw\">end</span>\n\
      104:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Write the given <tt>level</tt>, <tt>name</tt>, <tt>frame</tt>, and
      <tt>msg</tt> to the logfile.
      </p>
    params: ( time, level, name, frame, msg )
  category: Instance
  type: Public
- methods: 
  - visibility: protected
    aref: M000199
    name: initialize
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/logger/coloroutputter.rb, line 83</span>\n\
      83:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">initialize</span>( <span class=\"ruby-identifier\">uri</span>, <span class=\"ruby-identifier\">description</span>=<span class=\"ruby-constant\">DEFAULT_DESCRIPTION</span>, <span class=\"ruby-identifier\">format</span>=<span class=\"ruby-constant\">DEFAULT_FORMAT</span> ) <span class=\"ruby-comment cmt\"># :notnew:</span>\n\
      84:         <span class=\"ruby-keyword kw\">super</span>\n\
      85:         <span class=\"ruby-ivar\">@color_scheme</span> = <span class=\"ruby-constant\">DEFAULT_COLOR_SCHEME</span>.<span class=\"ruby-identifier\">dup</span>\n\
      86:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Override the default to add color scheme instance variable
      </p>
    params: ( uri, description=DEFAULT_DESCRIPTION, format=DEFAULT_FORMAT )
  category: Instance
  type: Protected

sectitle

--- 

constants

--- 
- name: SVNRev
  desc: |+
    
    SVN Revision
    
  value: "%q$Rev: 430 $"
- name: SVNId
  desc: |+
    
    SVN Id
    
  value: "%q$Id: coloroutputter.rb 430 2008-01-18 20:36:29Z deveiant $"
- name: AnsiAttributes
  desc: |+
    
    Set some ANSI escape code constants (Shamelessly stolen from Perl&#8216;s
    Term::ANSIColor by Russ Allbery &lt;rra@stanford.edu&gt; and Zenin
    &lt;zenin@best.com&gt;
    
  value: "{         'clear'      =&gt; 0,         'reset'      =&gt; 0,         'bold'       =&gt; 1,         'dark'       =&gt; 2,         'underline'  =&gt; 4,         'underscore' =&gt; 4,         'blink'      =&gt; 5,         'reverse'    =&gt; 7,         'concealed'  =&gt; 8,          'black'      =&gt; 30,   'on_black'   =&gt; 40,          'red'        =&gt; 31,   'on_red'     =&gt; 41,          'green'      =&gt; 32,   'on_green'   =&gt; 42,          'yellow'     =&gt; 33,   'on_yellow'  =&gt; 43,          'blue'       =&gt; 34,   'on_blue'    =&gt; 44,          'magenta'    =&gt; 35,   'on_magenta' =&gt; 45,          'cyan'       =&gt; 36,   'on_cyan'    =&gt; 46,          'white'      =&gt; 37,   'on_white'   =&gt; 47"
- name: DEFAULT_COLOR_SCHEME
  desc: |+
    
    Default color map: :level =&gt; %w{color scheme}
    
  value: "{         :debug        =&gt; %w{dark white},         :info     =&gt; %w{cyan},         :notice       =&gt; %w{bold cyan},         :warning  =&gt; %w{bold yellow},         :error        =&gt; %w{bold red},         :crit     =&gt; %w{bold white on_red},         :alert        =&gt; %w{bold blink white on_red},         :emerg        =&gt; %w{bold blink yellow on_red},     }"
- name: DEFAULT_DESCRIPTION
  desc: |+
    
    Default decription used when creating instances
    
  value: "&quot;Logging Outputter&quot;"
- name: DEFAULT_FORMAT
  desc: |+
    
    The default logging output format
    
  value: "%q{#{time.strftime('%Y/%m/%d %H:%M:%S')} [#{level}]: #{name} } +             %q{#{frame ? '('+frame+')' : ''}: #{msg}}"

[Validate]

Generated with the Darkfish Rdoc Generator.