<NME> basic.rb
<BEF> # encoding: utf-8

require_relative "encoding"

module Rango
  module RackDebug
    def call(env)
      Rango.logger.info("Middleware #{self.class} executed")
      returned = super(env)
      end

      def call(env)
        Rack::Lint.new(@app).call(env)
        Rango::Middlewares::Encoding.new(@app).call(env)
        Rack::MethodOverride.new(@app).call(env) # _method: put etc

        @app.call(env)

        Rack::ContentLength.new(@app).call(env)
        Rack::Head.new(@app).call(env)

        # serve static files
        if Project.settings.media_prefix
        @@media_prefix = media_prefix
      end

      @@media_prefix = ""

      attr_accessor :before, :after
          # "public" in the current directory (ie public/css/* and public/images/*)
          Rango.logger.info("Media files are available on #{Project.settings.media_prefix}")
          options = {urls: [Project.settings.media_prefix]}
          Rack::Static.new(@app, options).call(env)
        else
          Rango.logger.info("Media files are routed directly to the /")
          Rango.import("rack/middlewares/static.rb")
          Rango::Static.new(@app).call(env)
        end

        # cookies
        Rack::Session::Cookie.new(@app, path: '/').call(env)
        #, key: 'rack.session', domain: 'foo.com', path: '/', expire_after: 2592000, secret: 'change_me'
      end

    end
  end
end
        # Matryoshka principle
        # MethodOverride.new(Encoding.new(@app))
        unless @@called
          middlewares = self.before.reverse + self.after.reverse
          @app = middlewares.inject(@app) do |app, klass|
            args = Array.new
            if klass.is_a?(Array)
              klass, args = klass
              args = [args]
              Rango.logger.debug("#{klass}.new(app, #{args.map { |arg| arg.inspect }.join(", ")})")
            else
              Rango.logger.debug("#{klass}.new(app)")
            end
            klass.new(app, *args).extend(RackDebug)
          end
        end
        @@called = true
        @app.call(env)
      end

      def static_files_serving
        if self.class.media_prefix.empty?
          Rango.logger.info("Media files are routed directly to the /")
          require "rango/rack/middlewares/static"
          self.before.unshift Rango::Middlewares::Static
        else
          # use Rack::Static, :urls => ["/media"]
          # will serve all requests beginning with /media from the "media" folder
          # located in the current directory (ie media/*).

          # use Rack::Static, :urls => ["/css", "/images"], :root => "public"
          # will serve all requests beginning with /css or /images from the folder
          # "public" in the current directory (ie public/css/* and public/images/*)
          Rango.logger.info("Media files are available on #{self.class.media_prefix}")
          options = {urls: [self.class.media_prefix]}
          self.before.unshift [Rack::Static, options]
        end
      end
    end
  end
end

<MSG> Logging for basic middleware

<DFF> @@ -10,14 +10,14 @@ module Rango
       end
 
       def call(env)
-        Rack::Lint.new(@app).call(env)
-        Rango::Middlewares::Encoding.new(@app).call(env)
-        Rack::MethodOverride.new(@app).call(env) # _method: put etc
+        Rango.logger.debug(Rango::Middlewares::Encoding.new(@app).call(env))
+        Rango.logger.debug(Rack::MethodOverride.new(@app).call(env)) # _method: put etc
 
-        @app.call(env)
+        Rango.logger.debug("Calling app #{@app.inspect}: #{@app.call(env).inspect}")
 
-        Rack::ContentLength.new(@app).call(env)
-        Rack::Head.new(@app).call(env)
+        Rango.logger.debug(Rack::ContentType.new(@app).call(env))
+        Rango.logger.debug(Rack::ContentLength.new(@app).call(env))
+        Rango.logger.debug(Rack::Head.new(@app).call(env))
 
         # serve static files
         if Project.settings.media_prefix
@@ -30,18 +30,17 @@ module Rango
           # "public" in the current directory (ie public/css/* and public/images/*)
           Rango.logger.info("Media files are available on #{Project.settings.media_prefix}")
           options = {urls: [Project.settings.media_prefix]}
-          Rack::Static.new(@app, options).call(env)
+          Rango.logger.debug(Rack::Static.new(@app, options).call(env))
         else
           Rango.logger.info("Media files are routed directly to the /")
           Rango.import("rack/middlewares/static.rb")
-          Rango::Static.new(@app).call(env)
+          Rango.logger.debug(Rango::Static.new(@app).call(env))
         end
 
         # cookies
-        Rack::Session::Cookie.new(@app, path: '/').call(env)
+        Rango.logger.debug(Rack::Session::Cookie.new(@app, path: '/').call(env))
         #, key: 'rack.session', domain: 'foo.com', path: '/', expire_after: 2592000, secret: 'change_me'
       end
-
     end
   end
 end

Logging for basic middleware