Module: Sinatra::Verbose

Defined in:
lib/sinatra/verbose.rb,
lib/sinatra/verbose/version.rb

Overview

Sinatra::Verbose

Extension to log verbosely. Useful during development, since it will automatically log all the blocks that are invoked.

Usage

Classic Application

To enable the verbose logger in a classic application all you need to do is require it:

require "sinatra"
require "sinatra/verbose" if development?

# Your classic application code goes here...

Modular Application

To enable the verbose logger in a modular application all you need to do is require it, and then, register it:

require "sinatra/base"
require "sinatra/verbose"

class MyApp < Sinatra::Base
  configure :development do
    register Sinatra::Verbose
  end

  # Your modular application code goes here...
end

Constant Summary collapse

VERSION =
'0.0.1'

Instance Method Summary collapse

Instance Method Details

#after(path = nil, options = {}, &block) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/sinatra/verbose.rb', line 46

def after(path = nil, options = {}, &block)
  blk, block = block, Proc.new do
    logger.info "passing through an after block at #{blk.source_location.join(':')}"
    blk.call
  end
  super path, options, &block
end

#before(path = nil, options = {}, &block) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/sinatra/verbose.rb', line 38

def before(path = nil, options = {}, &block)
  blk, block = block, Proc.new do
    logger.info "passing through a before block at #{blk.source_location.join(':')}"
    blk.call
  end
  super path, options, &block
end

#error(*codes, &block) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/sinatra/verbose.rb', line 54

def error(*codes, &block)
  blk, block = block, Proc.new do
    logger.info "passing through an error block at #{blk.source_location.join(':')}"
    blk.call
  end
  super codes, &block
end