mod_log_slow_events/mod_log_slow_events.lua
changeset 2853 5e74028557dc
parent 2300 8c0bf3151e37
child 2854 3ba8fd1a297e
equal deleted inserted replaced
2852:232da6b1d2c1 2853:5e74028557dc
       
     1 module:set_global();
       
     2 
     1 local time = require "socket".gettime;
     3 local time = require "socket".gettime;
     2 local base64_decode = require "util.encodings".base64.decode;
     4 local base64_decode = require "util.encodings".base64.decode;
     3 
     5 
     4 local max_seconds = module:get_option_number("log_slow_events_threshold", 0.5);
     6 local max_seconds = module:get_option_number("log_slow_events_threshold", 0.5);
     5 
     7 
    50 		module:log("warn", "Slow event '%s' took %0.2fs: %s", event_name, duration, next(data) and table.concat(data, ", ") or "no recognised data");
    52 		module:log("warn", "Slow event '%s' took %0.2fs: %s", event_name, duration, next(data) and table.concat(data, ", ") or "no recognised data");
    51 	end
    53 	end
    52 	return ret;
    54 	return ret;
    53 end
    55 end
    54 
    56 
    55 module:wrap_event(false, event_wrapper);
       
    56 local http_events = require "net.http.server"._events;
    57 local http_events = require "net.http.server"._events;
    57 module:wrap_object_event(http_events, false, event_wrapper);
    58 module:wrap_object_event(http_events, false, event_wrapper);
    58 
    59 
       
    60 function module.add_host(module)
       
    61 	module:wrap_event(false, event_wrapper);
       
    62 end