Class: Arrow::Logger::HtmlOutputter
- Inherits:
-
FileOutputter
- Object
- Outputter
- FileOutputter
- Arrow::Logger::HtmlOutputter
- Includes:
- HTMLUtilities
- Defined in:
- lib/arrow/logger/htmloutputter.rb
Overview
Output logging messages in HTML fragments with classes that match their level.
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
"HTML Fragment Logging 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 FileOutputter
Constants inherited from Outputter
Instance Attribute Summary
Attributes inherited from FileOutputter
Attributes inherited from Outputter
Instance Method Summary collapse
-
#initialize(uri, description = DEFAULT_DESCRIPTION, format = HTML_FORMAT) ⇒ HtmlOutputter
constructor
Override the default argument values.
-
#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) ⇒ HtmlOutputter
Override the default argument values.
34 35 36 |
# File 'lib/arrow/logger/htmloutputter.rb', line 34 def initialize( uri, description=DEFAULT_DESCRIPTION, format=HTML_FORMAT ) # :notnew: super 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 $stderr.
44 45 46 47 48 49 50 |
# File 'lib/arrow/logger/htmloutputter.rb', line 44 def write( time, level, name, frame, msg ) escaped_msg = escape_html( msg ) escaped_name = escape_html( name ) html = @format.interpolate( binding ) @io.puts( html ) end |