'qctm_cron_task_log', 'primary' => 'id_cron_task_log', 'fields' => array( 'id_cron_task' => array('type' => self::TYPE_INT,'validate' => 'isUnsignedId','required' => true), 'status' => array('type' => self::TYPE_INT,'validate' => 'isUnsignedId','required' => true), 'error_message' => array('type' => self::TYPE_STRING,'validate' => 'isString'), 'execution_time' => array('type' => self::TYPE_FLOAT,'validate' => 'isFloat'), 'date_add' => array('type' => self::TYPE_DATE,'validate' => 'isDate'), ), ); /** * Add a log entry for a task execution * * @param int $idCronTask * @param int $status * @param string|null $errorMessage * @param float $executionTime * @return bool */ public static function addLog($idCronTask, $status, $errorMessage = null, $executionTime = 0) { $log = new self(); $log->id_cron_task = (int) $idCronTask; $log->status = $status; $log->error_message = $errorMessage; $log->execution_time = (float) $executionTime; return $log->add(); } /** * Delete logs older than specified number of days * * @param int $days * @return bool */ public static function deleteOlderThan($days) { return Db::getInstance()->execute( 'DELETE FROM `' . _DB_PREFIX_ . 'qctm_cron_task_log` WHERE `date_add` < DATE_SUB(NOW(), INTERVAL ' . (int) $days . ' DAY)' ); } public static function getStatuses() { static $statuses = null; if ($statuses === null) { $module = Module::getInstanceByName('qlocrontaskmanager'); $statuses = array( self::QCTM_CRON_TASK_LOG_STATUS_SUCCESS => $module->l('Success'), self::QCTM_CRON_TASK_LOG_STATUS_ERROR => $module->l('Error'), ); } return $statuses; } }