Release
This commit is contained in:
23
web/api/snow_log.php
Normal file
23
web/api/snow_log.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
require __DIR__ . '/../lib/app.php';
|
||||
header('Content-Type: application/json');
|
||||
@ini_set('display_errors','0');
|
||||
@error_reporting(0);
|
||||
|
||||
$n = isset($_GET['n']) ? (int)$_GET['n'] : 500;
|
||||
if ($n < 1) $n = 200;
|
||||
if ($n > 5000) $n = 5000;
|
||||
|
||||
$l = $_GET['level'] ?? 'info';
|
||||
$levels = ['debug','info','notice','warning','err'];
|
||||
$level = in_array($l,$levels,true) ? $l : 'info';
|
||||
|
||||
$out = [];
|
||||
$rc = 0;
|
||||
|
||||
$cmd = '/usr/bin/sudo /usr/local/bin/snowpanel-logdump ' . escapeshellarg((string)$n) . ' ' . escapeshellarg($level) . ' 2>&1';
|
||||
@exec($cmd, $out, $rc);
|
||||
|
||||
$lines = array_values(array_filter($out, static function($x){ return trim($x) !== ''; }));
|
||||
|
||||
echo json_encode(['ok'=>!empty($lines), 'lines'=>$lines], JSON_UNESCAPED_SLASHES);
|
||||
Reference in New Issue
Block a user