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 +$stderr+ instead of
env['rack.errors']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 plugin :common_logger, use_request_ip: true
Keyword Arguments:
method |
Specifies the method to call on the logger object when logging. |
use_request_ip |
Use |
Classes and Modules
Constants
| SCOPE_INSTANCE_VARIABLES | = | [:@_request_timer].freeze |
Public Class methods
configure(app, logger=nil, opts=(no_positional_opts = true; OPTS), method: opts[:method], use_request_ip: false, **kw)
[show source]
# File lib/roda/plugins/common_logger.rb 35 def self.configure(app, logger=nil, opts=(no_positional_opts = true; OPTS), method: opts[:method], use_request_ip: false, **kw) 36 RodaPlugins.check_keywords("the common_logger plugin", no_positional_opts, opts, kw) 37 38 common_logger = app.opts[:common_logger] = logger || app.opts[:common_logger] || $stderr # RODA4: drop setting of option, no longer used 39 app.opts[:common_logger_meth] = common_logger.method(method || (common_logger.respond_to?(:write) ? :write : :<<)) 40 app.opts[:common_logger_use_request_ip] = use_request_ip # RODA4: Deefault to true 41 end
start_timer()
A timer object for calculating elapsed time.
[show source]
# File lib/roda/plugins/common_logger.rb 45 def self.start_timer 46 # RODA4.1: Remove 47 Process.clock_gettime(Process::CLOCK_MONOTONIC) 48 end