webmcp

annotate framework/env/__init.lua @ 302:04b648660f9a

Time triple (cpu/db/total) for trace system
author jbe
date Sun Mar 22 20:06:26 2015 +0100 (2015-03-22)
parents 1fbdccf4f8e9
children 1c3ba14bd679
rev   line source
jbe@203 1 -- string localization function
jbe/bsw@0 2 function _(text, replacements)
jbe/bsw@0 3 local text = locale._get_translation_table()[text] or text
jbe/bsw@0 4 if replacements then
jbe/bsw@0 5 return (
jbe/bsw@0 6 string.gsub(
jbe/bsw@0 7 text,
jbe/bsw@0 8 "#{(.-)}",
jbe/bsw@0 9 function (placeholder)
jbe/bsw@0 10 return replacements[placeholder]
jbe/bsw@0 11 end
jbe/bsw@0 12 )
jbe/bsw@0 13 )
jbe/bsw@0 14 else
jbe/bsw@0 15 return text
jbe/bsw@0 16 end
jbe/bsw@0 17 end
jbe@203 18
jbe@203 19 --[[--
jbe@203 20 cloned_table = -- newly generated table
jbe@203 21 table.new(
jbe@203 22 table_or_nil -- keys of a given table will be copied to the new table
jbe@203 23 )
jbe@203 24
jbe@203 25 If a table is given, then a cloned table is returned.
jbe@203 26 If nil is given, then a new empty table is returned.
jbe@203 27
jbe@203 28 --]]--
jbe@203 29 function table.new(tbl)
jbe@240 30 local new_tbl = {}
jbe@203 31 if tbl then
jbe@203 32 for key, value in pairs(tbl) do
jbe@203 33 new_tbl[key] = value
jbe@203 34 end
jbe@203 35 end
jbe@203 36 return new_tbl
jbe@203 37 end
jbe@203 38 --//--
jbe@203 39
jbe@286 40 -- load libraries (except "multirand", which must be loaded after forking)
jbe@203 41 extos = require 'extos'
jbe@203 42 nihil = require 'nihil'
jbe@203 43 mondelefant = require 'mondelefant'
jbe@203 44 atom = require 'atom'
jbe@203 45 json = require 'json'
jbe@203 46 require 'mondelefant_atom_connector'
jbe@286 47 -- NOTE: "multirand" library is loaded in mcp.lua after forking
jbe@203 48
jbe@295 49 -- setup mondelefant
jbe@295 50 mondelefant.connection_prototype.error_objects = true
jbe@295 51 function mondelefant.connection_prototype:sql_tracer(command)
jbe@295 52 if trace.is_disabled() then
jbe@295 53 return
jbe@295 54 end
jbe@295 55 local start_time = extos.monotonic_hires_time()
jbe@295 56 return function(error_info)
jbe@295 57 trace.sql{
jbe@295 58 command = command,
jbe@295 59 execution_time = extos.monotonic_hires_time() - start_time,
jbe@295 60 error_position = error_info and error_info.position or nil
jbe@295 61 }
jbe@295 62 end
jbe@295 63 end
jbe@295 64
jbe@206 65 --[[--
jbe@206 66 config -- table to store application configuration
jbe@206 67
jbe@206 68 'config' is a global table, which can be modified by a config file of an application to modify the behaviour of that application.
jbe@206 69 --]]--
jbe@206 70 config = {}
jbe@206 71 --//--
jbe@206 72

Impressum / About Us