Output logging messages in ANSI colors according to their level
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
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
--- SEC00066
--- ""
---
- name: color_scheme
rw: R
a_desc: |+
The color scheme hash for this logger
---
- 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
---
---
- 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‘s
Term::ANSIColor by Russ Allbery <rra@stanford.edu> and Zenin
<zenin@best.com>
value: "{ 'clear' => 0, 'reset' => 0, 'bold' => 1, 'dark' => 2, 'underline' => 4, 'underscore' => 4, 'blink' => 5, 'reverse' => 7, 'concealed' => 8, 'black' => 30, 'on_black' => 40, 'red' => 31, 'on_red' => 41, 'green' => 32, 'on_green' => 42, 'yellow' => 33, 'on_yellow' => 43, 'blue' => 34, 'on_blue' => 44, 'magenta' => 35, 'on_magenta' => 45, 'cyan' => 36, 'on_cyan' => 46, 'white' => 37, 'on_white' => 47"
- name: DEFAULT_COLOR_SCHEME
desc: |+
Default color map: :level => %w{color scheme}
value: "{ :debug => %w{dark white}, :info => %w{cyan}, :notice => %w{bold cyan}, :warning => %w{bold yellow}, :error => %w{bold red}, :crit => %w{bold white on_red}, :alert => %w{bold blink white on_red}, :emerg => %w{bold blink yellow on_red}, }"
- name: DEFAULT_DESCRIPTION
desc: |+
Default decription used when creating instances
value: ""Logging Outputter""
- 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}}"
Generated with the Darkfish Rdoc Generator.