Class: Arrow::Logger::ArrayOutputter
- Includes:
- 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 <[email protected]>
Please see the file LICENSE in the top-level directory for licensing details.
Constant Summary collapse
- 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 HTMLUtilities
HTMLUtilities::ARRAY_HTML_CONTAINER, HTMLUtilities::HASH_HTML_CONTAINER, HTMLUtilities::HASH_PAIR_HTML, HTMLUtilities::IMMEDIATE_OBJECT_HTML_CONTAINER, HTMLUtilities::IVAR_HTML_FRAGMENT, HTMLUtilities::OBJECT_HTML_CONTAINER, HTMLUtilities::THREAD_DUMP_KEY
Constants inherited from Outputter
Instance Attribute Summary collapse
-
#array ⇒ Object
readonly
The Array any output log messages get appended to.
Attributes inherited from Outputter
Instance Method Summary collapse
-
#initialize(uri, description = DEFAULT_DESCRIPTION, format = HTML_FORMAT) ⇒ ArrayOutputter
constructor
Override the default to intitialize the Array.
-
#write(time, level, name, frame, msg) ⇒ Object
Write the given
level
,name
,frame
, andmsg
to the target output mechanism.
Methods included from HTMLUtilities
escape_html, make_html_for_object, make_object_html_wrapper
Methods inherited from Outputter
create, derivativeDirs, #inspect, parse_uri
Constructor Details
#initialize(uri, description = DEFAULT_DESCRIPTION, format = HTML_FORMAT) ⇒ ArrayOutputter
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
#array ⇒ Object (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
#write(time, level, name, frame, msg) ⇒ Object
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 |