Class: Arrow::Logger::ApacheOutputter
- Defined in:
- lib/arrow/logger/apacheoutputter.rb
Overview
The Arrow::Logger::ApacheOutputter class, a derivative of Apache::Logger::Outputter. Instances of this class write log messages of the corresponding error level to the Apache log
Authors
-
Michael Granger <[email protected]>
Please see the file LICENSE in the top-level directory for licensing details.
Constant Summary collapse
- DefaultDescription =
The default description
"Apache Log Outputter"
- DefaultFormat =
The default interpolatable string that’s used to build the message to output
%q{#{name}#{frame ? '('+frame+')' : ''}: #{msg[0,2048]}}
- LEVELS =
The Logger log levels (copied for easy access)
Arrow::Logger::LEVELS
Constants inherited from Outputter
Outputter::DEFAULT_DESCRIPTION, Outputter::DEFAULT_FORMAT
Instance Attribute Summary
Attributes inherited from Outputter
Instance Method Summary collapse
-
#initialize(uri, description = DefaultDescription, format = DefaultFormat) ⇒ ApacheOutputter
constructor
Create a new Arrow::Logger::ApacheOutputter object that will write to the apache log, and use the given
description
andformat
. -
#write(time, level, name, frame, msg) ⇒ Object
Write the given
level
,name
,frame
, andmsg
to the target output mechanism.
Methods inherited from Outputter
create, derivativeDirs, #inspect, parse_uri
Constructor Details
#initialize(uri, description = DefaultDescription, format = DefaultFormat) ⇒ ApacheOutputter
Create a new Arrow::Logger::ApacheOutputter object that will write to the apache log, and use the given description
and format
.
37 38 39 |
# File 'lib/arrow/logger/apacheoutputter.rb', line 37 def initialize( uri, description=DefaultDescription, format=DefaultFormat ) 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.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/arrow/logger/apacheoutputter.rb', line 48 def write( time, level, name, frame, msg ) return unless defined?( ::Apache ) srvr = ::Apache.request.server return unless srvr.loglevel >= LEVELS[ level ] # Translate calls to log.warning into Apache::Server#log_warn level = :warn if level == :warning logMethod = srvr.method( "log_#{level}" ) super {|msg| # Escape any unexpanded sprintf format patterns msg.gsub!( /%/, '%%' ) logMethod.call( msg ) } end |