webmcp

diff framework/env/__init.lua @ 295:1fbdccf4f8e9

Always enable SQL tracer (within framework/env/__init.lua); Record execution time of SQL statements
author jbe
date Sun Mar 22 18:40:07 2015 +0100 (2015-03-22)
parents fc2aba7d5db9
children 1c3ba14bd679
line diff
     1.1 --- a/framework/env/__init.lua	Sun Mar 22 17:33:37 2015 +0100
     1.2 +++ b/framework/env/__init.lua	Sun Mar 22 18:40:07 2015 +0100
     1.3 @@ -41,12 +41,27 @@
     1.4  extos       = require 'extos'
     1.5  nihil       = require 'nihil'
     1.6  mondelefant = require 'mondelefant'
     1.7 -mondelefant.connection_prototype.error_objects = true
     1.8  atom        = require 'atom'
     1.9  json        = require 'json'
    1.10  require 'mondelefant_atom_connector'
    1.11  -- NOTE: "multirand" library is loaded in mcp.lua after forking
    1.12  
    1.13 +-- setup mondelefant
    1.14 +mondelefant.connection_prototype.error_objects = true
    1.15 +function mondelefant.connection_prototype:sql_tracer(command)
    1.16 +  if trace.is_disabled() then
    1.17 +    return
    1.18 +  end
    1.19 +  local start_time = extos.monotonic_hires_time()
    1.20 +  return function(error_info)
    1.21 +    trace.sql{
    1.22 +      command        = command,
    1.23 +      execution_time = extos.monotonic_hires_time() - start_time,
    1.24 +      error_position = error_info and error_info.position or nil
    1.25 +    }
    1.26 +  end
    1.27 +end
    1.28 +
    1.29  --[[--
    1.30  config  -- table to store application configuration
    1.31  

Impressum / About Us