-
Notifications
You must be signed in to change notification settings - Fork 1
/
bitrix-error.php
76 lines (58 loc) · 1.65 KB
/
bitrix-error.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/*
Получение ошибок
Указываются опции: лимит и показывать ли имя файла лога
*/
namespace Bitrixcli;
require(__DIR__ . '/lib/cli-cms.php');
class ErrorCli extends BitrixCli {
protected $limit = 13, $isShowLogFileName = false;
public static $cliParams = array(
'noVal' // без значения
=> array('f' => 'file'),
'val' // со значением
=> array('l' => 'limit'),
'optionVal' // с необязательным значением
=> array(),
)
;
public function __construct($BitrixCMS) {
parent::__construct($BitrixCMS);
}
public function run() {
try {
$this->getParms();
$this->outputLog();
} catch (Exception $e) {
$this->error($e);
}
}
protected function getParms() {
$params = $this->getCliParms();
if(isset($params['l'])) {
$this->limit = $params['l'];
}
if(isset($params['limit'])) {
$this->limit = $params['limit'];
}
if(isset($params['f'])) {
$this->isShowLogFileName = true;
}
if(isset($params['file'])) {
$this->isShowLogFileName = true;
}
}
protected function outputLog() {
$config = $this->BitrixCMS->getConfig();
$logFile =& $config['exception_handling']['value']['log']['settings']['file'];
if(!isset($logFile) || !$logFile) throw new Exception("Empty settings: log file");
if($this->isShowLogFileName) {
echo $logFile . PHP_EOL;
}
$cmd = sprintf('tail -n %d %s', $this->limit, escapeshellarg($logFile));
echo shell_exec($cmd);
die();
}
}
$ErrorCli = new ErrorCli($BitrixCMS);
$ErrorCli->run();