Files
Varaverk/Plugin/usr/local/emhttp/plugins/varaverk/api/log.php
T
Gmer4Lfe 6050816fe4 Scheduler: card layout, per-job logs, live log panel
- Per-job log files replace single jobs.log: each script writes to
  /var/log/varaverk/<Category>/<script>.log mirroring the job ID
- api/log.php: serves last 200 lines of a job's log file with mtime
  timestamp; supports POST ?clear=1 to truncate
- Scheduler page redesigned as full-width cards (one per orchestrator)
  with Save + Log buttons; Log toggles an inline panel that polls
  every 3 seconds and auto-scrolls — same pattern as unRAID User Scripts
- Children shown under Advanced with identical per-job log panels
- CSS: vv-sched-card, vv-log-panel, vv-log-pre, vv-btn-sm
2026-05-23 17:17:09 -04:00

31 lines
809 B
PHP

<?php
header('Content-Type: application/json');
require_once dirname(__DIR__) . '/include/scheduler.php';
$id = trim($_GET['id'] ?? '');
if (!$id || !preg_match('/^[a-zA-Z0-9_.\/\-]+\.sh$/', $id) || str_contains($id, '..')) {
echo json_encode(['ok' => false, 'error' => 'Invalid job id']);
exit;
}
$logFile = vv_job_log_path($id);
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_GET['clear'])) {
if (file_exists($logFile)) file_put_contents($logFile, '');
echo json_encode(['ok' => true]);
exit;
}
if (!file_exists($logFile)) {
echo json_encode(['ok' => true, 'content' => '', 'ts' => 0]);
exit;
}
$lines = array_slice(file($logFile) ?: [], -200);
echo json_encode([
'ok' => true,
'content' => implode('', $lines),
'ts' => filemtime($logFile),
]);