Class: Racknga::Middleware::Log
- Inherits:
- 
      Object
      
        - Object
- Racknga::Middleware::Log
 
- Defined in:
- lib/racknga/middleware/log.rb
Overview
This is a middleware that puts access logs to groonga database. It may useful for OLAP (OnLine Analytical Processing).
Usage:
use Racnkga::Middleware::Log, :database_path => "var/log/db" run YourApplication
Defined Under Namespace
Classes: Logger
Constant Summary
- LOGGER =
- "racknga.logger"
Instance Method Summary (collapse)
- 
  
    
      - (Object) call(environment) 
    
    
  
  
  
  
  
  
  
  
    For Rack. 
- 
  
    
      - (Object) close_database 
    
    
  
  
  
  
  
  
  
  
    close the cache database. 
- 
  
    
      - (Object) ensure_database 
    
    
  
  
  
  
  
  
  
  
    ensures creating cache database. 
- 
  
    
      - (Log) initialize(application, options = {}) 
    
    
  
  
    constructor
  
  
  
  
  
  
  
    database path to be stored caches. 
Constructor Details
- (Log) initialize(application, options = {})
database path to be stored caches.
| 37 38 39 40 41 42 43 44 | # File 'lib/racknga/middleware/log.rb', line 37 def initialize(application, ={}) @application = application = Utils.( || {}) database_path = [:database_path] raise ArgumentError, ":database_path is missing" if database_path.nil? @database = LogDatabase.new(database_path) @logger = Logger.new(@database) end | 
Instance Method Details
- (Object) call(environment)
For Rack.
| 47 48 49 50 51 52 53 54 55 56 57 58 | # File 'lib/racknga/middleware/log.rb', line 47 def call(environment) environment[LOGGER] = @logger start_time = Time.now status, headers, body = @application.call(environment) end_time = Time.now request = Rack::Request.new(environment) log(start_time, end_time, request, status, headers, body) [status, headers, body] end | 
- (Object) close_database
close the cache database.
| 66 67 68 | # File 'lib/racknga/middleware/log.rb', line 66 def close_database @database.close_database end | 
- (Object) ensure_database
ensures creating cache database.
| 61 62 63 | # File 'lib/racknga/middleware/log.rb', line 61 def ensure_database @database.ensure_database end | 
 
         
         
        