class DRbService::HtmlLogFormatter
An alternate formatter for Logger instances that outputs div
HTML fragments.
Usage¶ ↑
require 'drbservice/utils' DRbService.logger.formatter = DRbService::HtmlLogFormatter.new( DRbService.logger )
Version¶ ↑
$Id: utils.rb,v 87bc5aa9e2be 2011/08/29 21:05:42 ged $
Authors¶ ↑
-
Michael Granger <ged@FaerieMUD.org>
Copyright © 2010, Michael Granger All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
Neither the name of the author/s, nor the names of the project’s contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Constants
- HTML_LOG_FORMAT
The default HTML fragment that’ll be used as the template for each log message.
Attributes
The HTML fragment that will be used as a format() string for the log
Public Instance Methods
Return a log message composed out of the arguments formatted using the formatter’s format string
# File lib/drbservice/utils.rb, line 287 def call( severity, time, progname, msg ) args = [ time.strftime( '%Y-%m-%d %H:%M:%S' ), # %1$s time.usec, # %2$d Process.pid, # %3$d Thread.current == Thread.main ? 'main' : Thread.object_id, # %4$s severity.downcase, # %5$s progname, # %6$s html_escape( msg ).gsub(/\n/, '<br />') # %7$s ] return self.format % args end
Protected Instance Methods
Override the logging formats with ones that generate HTML fragments
# File lib/drbservice/utils.rb, line 270 def initialize( logger, format=HTML_LOG_FORMAT ) # :notnew: @logger = logger @format = format super() end