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 if explicit logger not passed

Example:

plugin :common_logger
plugin :common_logger, $stdout
plugin :common_logger, Logger.new('filename')

Methods

Public Class

  1. configure
  2. load_dependencies
  3. start_timer

Public Class methods

configure (app, logger=nil)
[show source]
# File lib/roda/plugins/common_logger.rb, line 26
def self.configure(app, logger=nil)
  app.opts[:common_logger] = logger || app.opts[:common_logger] || $stderr
  app.opts[:common_logger_meth] = app.opts[:common_logger].method(logger.respond_to?(:write) ? :write : :<<)
end
load_dependencies (app, _=nil)
[show source]
# File lib/roda/plugins/common_logger.rb, line 21
def self.load_dependencies(app, _=nil)
  app.plugin :_after_hook
  app.plugin :_before_hook
end
start_timer ()

A timer object for calculating elapsed time.

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