This extension is obsolete as Sinatra now provides access to a pattern object,
thanks to Mustermann, so that we no longer need to decompose Regexps.
If you're using this API directly, or via an extension that I'm unaware of...
Please let me know and we'll figure something out.
Its highly likely noone was using this extension directly, and possible that
only Namespace was the only consumer via internal usage.
So for now, I'm removing this extension until someone complains.
CustomLogger extension allows you to define your own logger instance
using +logger+ setting. That logger then will be available
as #logger helper method in your routes and views.
=== Classic Application
To define your custom logger instance in a classic application:
require 'sinatra'
require 'sinatra/custom_logger'
require 'logger'
set :logger, Logger.new(STDOUT)
get '/' do
logger.info 'Some message' # STDOUT logger is used
# Other code...
end
=== Modular Application
The same for modular application:
require 'sinatra/base'
require 'sinatra/custom_logger'
require 'logger'
class MyApp < Sinatra::Base
helpers Sinatra::CustomLogger
configure :development, :production do
logger = Logger.new(File.open("#{root}/log/#{environment}.log", 'a'))
logger.level = Logger::DEBUG if development?
set :logger, logger
end
get '/' do
logger.info 'Some message' # File-based logger is used
# Other code...
end
end