public function init() { $this->name = \Yii::t('skeeks/logdb/app', "Managing logs"); $this->modelShowAttribute = "id"; $this->modelClassName = LogDbTargetModel::className(); parent::init(); }
/** * Чистка логов старше чем (указать количество дней) * @param int $countDay количество дней */ public function actionLogs($countDay = 5) { if ($count = LogDbTargetModel::find()->where(['<=', 'log_time', time() - 3600 * 24 * $countDay])->count()) { $this->stdout("Total logs found: {$count}\n", Console::BOLD); $totalDeleted = LogDbTargetModel::deleteAll(['<=', 'log_time', time() - 3600 * 24 * $countDay]); $this->stdout("Total deleted: {$totalDeleted}\n"); } else { $this->stdout("Нечего удалять\n", Console::BOLD); } }
/** * Просмотр созданных бекапов баз данных */ public function actionClearLogs() { $deleted = LogDbTargetModel::deleteAll(['<=', 'log_time', \Yii::$app->formatter->asTimestamp(time()) - (int) \Yii::$app->logDbTargetSettings->storeLogsTime]); \Yii::info(\Yii::t('skeeks/logdb/app', 'The number of remote logging') . ": " . $deleted); }