Connector Open-Source Code
Browse connector files locally. Exchange API keys stay on your device.
ui/logs.php
<?php
// /opt/nuxvision_connector/ui/logs.php
declare(strict_types=1);
require_once __DIR__ . '/common.php';
$instanceId = to_int($_GET['instance_id'] ?? nv_instance_id_from_session(), 0);
if ($instanceId <= 0) $instanceId = 1;
$logType = (string)($_GET['type'] ?? 'runner'); // runner|tracker
if (!in_array($logType, ['runner','tracker'], true)) $logType = 'runner';
// Logs are always stored in the instance directory:
// - instances/<id>/runner.log
// - instances/<id>/tracker.log
if ($logType === 'runner') {
$logFile = nv_instance_default_log_path($instanceId); // instances/<id>/runner.log
} else { // tracker
$logFile = rtrim($INSTANCES_DIR, '/') . '/' . $instanceId . '/tracker.log';
}
$logReal = realpath($logFile);
$exists = ($logReal !== false && is_file($logReal));
$tail = to_int($_GET['tail'] ?? 300, 300);
if ($tail < 50) $tail = 50;
if ($tail > 5000) $tail = 5000;
// Disable stepper on logs page
render_header('NuxVision Connector', 'Logs', false);
?>
<div class="nv-card p-4 mb-3">
<div class="d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2">
<div>
<div class="h5 fw-bold mb-1">Instance <span class="mono">#<?=h((string)$instanceId)?></span> <?=h($logType)?> logs</div>
<div class="nv-muted small">
Path: <span class="mono"><?=h($logFile)?></span>
<?php if ($exists): ?>
• Size: <span class="mono"><?=h((string)filesize($logReal))?></span> bytes
<?php else: ?>
• <span class="text-warning">missing</span>
<?php endif; ?>
</div>
</div>
<div class="d-flex flex-wrap gap-2">
<a class="btn btn-soft" href="./index.php"><i class="bi bi-arrow-left me-1"></i>Back</a>
<a class="btn btn-soft" href="./nuxvision.php?instance_id=<?=h((string)$instanceId)?>"><i class="bi bi-wrench-adjustable-circle me-1"></i>Setup</a>
<a class="btn btn-soft" href="./index.php"><i class="bi bi-house me-1"></i>Home</a>
<a class="btn btn-soft" href="./logs.php?instance_id=<?=h((string)$instanceId)?>&type=<?=h($logType)?>&tail=<?=h((string)$tail)?>">
<i class="bi bi-arrow-clockwise me-1"></i>Refresh
</a>
</div>
</div>
<form class="d-flex gap-2 align-items-center mb-3" method="get" action="./logs.php">
<input type="hidden" name="instance_id" value="<?=h((string)$instanceId)?>">
<label class="nv-muted small">Log</label>
<select class="form-select form-select-sm" name="type" style="max-width:160px">
<option value="runner" <?= $logType==='runner' ? 'selected' : '' ?>>runner.log</option>
<option value="tracker" <?= $logType==='tracker' ? 'selected' : '' ?>>tracker.log</option>
</select>
<label class="nv-muted small">Tail</label>
<input class="form-control form-control-sm" style="max-width:120px" type="number" name="tail" value="<?=h((string)$tail)?>" min="50" max="5000">
<button class="btn btn-soft btn-sm" type="submit"><i class="bi bi-funnel me-1"></i>Apply</button>
</form>
<?php if (!$exists): ?>
<div class="alert alert-warning py-2 mb-0">
<i class="bi bi-exclamation-triangle me-1"></i>
Log file not found. Start the service and refresh.
</div>
<?php else: ?>
<pre class="nv-code" style="white-space:pre-wrap;word-break:break-word;margin:0;background:rgba(0,0,0,.25);border:1px solid rgba(255,255,255,.08);border-radius:14px;padding:12px;max-height:65vh;overflow:auto;"><?php
$cmd = 'tail -n ' . escapeshellarg((string)$tail) . ' ' . escapeshellarg($logReal) . ' 2>&1';
$out = shell_exec($cmd);
echo h((string)$out);
?></pre>
<?php endif; ?>
</div>
<?php
render_footer();