I want to log all requests after execution with interceptors. -i allowed hooks in config.php is my hook â
$hook['post_controller'] = array( 'class' => 'Db_log', 'function' => 'logQueries', 'filename' => 'db_log.php', 'filepath' => 'hooks' );
- and this is detonation of the hook â
class Db_log { function __construct() { } function logQueries() { $CI = & get_instance(); $filepath = APPPATH . 'logs/Query-log-' . date('Ym-d') . '.php'; $handle = fopen($filepath, "a+"); $times = $CI->db->query_times; foreach ($CI->db->queries as $key => $query) { $sql = $query . " \n Execution Time:" . $times[$key]; fwrite($handle, $sql . "\n\n"); } fclose($handle); } }
- creating a query_log file - but no records of saved queries
source share