-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b46b408
commit 0c9fe60
Showing
10 changed files
with
2,293 additions
and
404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
class ToolsController extends Controller | ||
{ | ||
public $layout = 'fullmenu'; | ||
|
||
public function actionIndex() | ||
{ | ||
$tools = array( | ||
array('name' => 'Visualizar Logs', 'url' => Yii::app()->createUrl('tools/viewLogs')), | ||
array('name' => 'OpCache', 'url' => Yii::app()->createUrl('tools/opcache')) | ||
|
||
); | ||
|
||
$this->render('index', array( | ||
'tools' => $tools, | ||
)); | ||
} | ||
public function actionOpcache() | ||
{ | ||
|
||
$this->layout = "reportsclean"; | ||
// Caminho completo para o OPcache GUI | ||
$opcacheGuiPath = Yii::getPathOfAlias('application.extensions.opcache-gui') . '/index.php'; | ||
// Verifica se o arquivo existe | ||
if (!file_exists($opcacheGuiPath)) { | ||
throw new CHttpException(404, 'OPcache GUI não encontrado.'); | ||
} | ||
|
||
// Inclui o arquivo do OPcache GUI | ||
require_once $opcacheGuiPath; | ||
|
||
Yii::app()->end(); // Finaliza o processamento Yii após exibir o OPcache GUI | ||
} | ||
|
||
public function actionViewLogs() | ||
{ | ||
// Caminho do diretório onde os logs são armazenados | ||
$logPath = "/app/app/runtime/" . INSTANCE . "/" . date("Y-m-d"); | ||
$logFiles = glob($logPath . '/application.log*'); // Encontra todos os arquivos de log | ||
$logs = []; | ||
|
||
// Ordena os arquivos para garantir que os mais recentes sejam processados primeiro | ||
rsort($logFiles); // Ordena os arquivos de forma decrescente (do mais recente para o mais antigo) | ||
|
||
if (!empty($logFiles)) { | ||
foreach ($logFiles as $file) { | ||
// Adiciona o cabeçalho com o nome do arquivo | ||
array_unshift($logs, ["type" => "header", "file" => basename($file)]); // Coloca no início | ||
|
||
// Abre o arquivo e lê linha por linha | ||
$fileHandle = fopen($file, 'r'); | ||
if ($fileHandle) { | ||
while (($line = fgets($fileHandle)) !== false) { | ||
array_unshift($logs, ["type" => "log", "line" => $line]); // Coloca no início | ||
} | ||
fclose($fileHandle); | ||
} | ||
} | ||
} | ||
|
||
$dataProvider = new CArrayDataProvider($logs, array( | ||
'id' => 'log', | ||
'pagination' => array( | ||
'pageSize' => 50, // Exibir 50 linhas por página | ||
), | ||
)); | ||
|
||
$this->render('viewLogs', array( | ||
'dataProvider' => $dataProvider, | ||
)); | ||
} | ||
|
||
|
||
} | ||
|
||
|
Oops, something went wrong.