module Roda::RodaPlugins::CommonLogger

  1. lib/roda/plugins/common_logger.rb

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


plugin :common_logger
plugin :common_logger, $stdout
plugin :common_logger,'filename')
plugin :common_logger,'filename'), method: :debug


Public Class

  1. configure
  2. start_timer

Public Class methods

configure(app, logger=nil, opts=OPTS)
[show source]
   # File lib/roda/plugins/common_logger.rb
26 def self.configure(app, logger=nil, opts=OPTS)
27   app.opts[:common_logger] = logger || app.opts[:common_logger] || $stderr
28   app.opts[:common_logger_meth] = app.opts[:common_logger].method(opts.fetch(:method){logger.respond_to?(:write) ? :write : :<<})
29 end

A timer object for calculating elapsed time.

[show source]
   # File lib/roda/plugins/common_logger.rb
33 def self.start_timer
34   Process.clock_gettime(Process::CLOCK_MONOTONIC)
35 end