Class: Arrow::Logger::ArrayOutputter
- Inherits:
-
Outputter
- Object
- Outputter
- Arrow::Logger::ArrayOutputter
- Includes:
- Arrow::HTMLUtilities
- Defined in:
- lib/arrow/logger/arrayoutputter.rb
Overview
Accumulate logging messages in HTML fragments into an Array which can later be fetched.
Authors
Michael Granger
Please see the file LICENSE in the top-level directory for licensing details.
Constant Summary
- DEFAULT_DESCRIPTION =
Default decription used when creating instances
"Array Outputter"
- HTML_FORMAT =
The default logging output format
%q{ <div class="log-message #{level}"> <span class="log-time">#{time.strftime('%Y/%m/%d %H:%M:%S')}</span> <span class="log-level">#{level}</span> : <span class="log-name">#{escaped_name}</span> <span class="log-frame">#{frame ? '('+frame+'): ' : ''}</span> <span class="log-message-text">#{escaped_msg}</span> </div> }
Constants included from Arrow::HTMLUtilities
ARRAY_HTML_CONTAINER, HASH_HTML_CONTAINER, HASH_PAIR_HTML, IMMEDIATE_OBJECT_HTML_CONTAINER, IVAR_HTML_FRAGMENT, OBJECT_HTML_CONTAINER, THREAD_DUMP_KEY
Constants inherited from Outputter
DEFAULT_DESCRIPTION, DEFAULT_FORMAT
Instance Attribute Summary
-
- (Object) array
readonly
The Array any output log messages get appended to.
Instance Method Summary
-
- (ArrayOutputter) initialize(uri, description = DEFAULT_DESCRIPTION, format = HTML_FORMAT)
constructor
Override the default to intitialize the Array.
-
- (Object) write(time, level, name, frame, msg)
Write the given level, name, frame, and msg to the target output mechanism.
Methods included from Arrow::HTMLUtilities
#escape_html, #make_html_for_object, #make_object_html_wrapper
Methods inherited from Outputter
create, derivativeDirs, #inspect, #inspection_details, parse_uri
Constructor Details
- (ArrayOutputter) initialize(uri, description = DEFAULT_DESCRIPTION, format = HTML_FORMAT)
Override the default to intitialize the Array.
34 35 36 37 |
# File 'lib/arrow/logger/arrayoutputter.rb', line 34 def initialize( uri, description=DEFAULT_DESCRIPTION, format=HTML_FORMAT ) # :notnew: @array = [] super end |
Instance Attribute Details
- (Object) array (readonly)
The Array any output log messages get appended to
45 46 47 |
# File 'lib/arrow/logger/arrayoutputter.rb', line 45 def array @array end |
Instance Method Details
- (Object) write(time, level, name, frame, msg)
Write the given level, name, frame, and msg to the target output mechanism. Subclasses can call this with a block which will be passed the formatted message. If no block is supplied by the child, this method will check to see if $DEBUG is set, and if it is, write the log message to $deferr.
53 54 55 56 57 58 59 |
# File 'lib/arrow/logger/arrayoutputter.rb', line 53 def write( time, level, name, frame, msg ) escaped_msg = escape_html( msg ) escaped_name = escape_html( name ) html = self.format.interpolate( binding ) @array << html end |