Module: Roda::RodaPlugins::CommonLogger
- Defined in:
- lib/roda/plugins/common_logger.rb
Overview
The common_logger plugin adds common logger support to Roda applications, similar to Rack::CommonLogger, with the following differences:
- Better performance
- Doesn't include middleware timing
- Doesn't proxy the body
- Doesn't support different capitalization of the Content-Length response header
- Logs to
$stderrinstead of env if explicit logger not passed
Example:
plugin :common_logger
plugin :common_logger, $stdout
plugin :common_logger, Logger.new('filename')
plugin :common_logger, Logger.new('filename'), method: :debug
Defined Under Namespace
Modules: InstanceMethods
Constant Summary collapse
- SCOPE_INSTANCE_VARIABLES =
[:@_request_timer].freeze
Class Method Summary collapse
Class Method Details
.configure(app, logger = nil, opts = OPTS) ⇒ Object
28 29 30 31 |
# File 'lib/roda/plugins/common_logger.rb', line 28 def self.configure(app, logger=nil, opts=OPTS) app.opts[:common_logger] = logger || app.opts[:common_logger] || $stderr app.opts[:common_logger_meth] = app.opts[:common_logger].method(opts.fetch(:method){logger.respond_to?(:write) ? :write : :<<}) end |
.start_timer ⇒ Object
:nocov:
35 36 37 |
# File 'lib/roda/plugins/common_logger.rb', line 35 def self.start_timer Process.clock_gettime(Process::CLOCK_MONOTONIC) end |