Add UART SET_LOG_LEVEL for runtime master ESP-IDF logging.
Expose the command via goTool CLI/REST and dashboard controls so log verbosity can be tuned without reflashing. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -219,6 +219,8 @@
|
||||
<dd class="col-7" x-text="state.master.running_partition || '—'"></dd>
|
||||
<dt class="col-5 text-muted">Deadzone</dt>
|
||||
<dd class="col-7" x-text="state.master.deadzone != null ? state.master.deadzone + ' LSB' : '—'"></dd>
|
||||
<dt class="col-5 text-muted">Log-Level</dt>
|
||||
<dd class="col-7" x-text="formatLogLevel(masterLogLevel)"></dd>
|
||||
<dt class="col-5 text-muted">LiPo 1</dt>
|
||||
<dd class="col-7" x-text="formatLipo(state.master?.lipo1)"></dd>
|
||||
<dt class="col-5 text-muted">LiPo 2</dt>
|
||||
@@ -264,6 +266,31 @@
|
||||
Restart
|
||||
</button>
|
||||
</div>
|
||||
<label class="form-label text-muted small mb-1 mt-3" for="master-log-level">
|
||||
ESP Log-Level (global)
|
||||
</label>
|
||||
<div class="d-flex flex-wrap gap-2 align-items-end">
|
||||
<select id="master-log-level" class="form-select form-select-sm config-input"
|
||||
x-model.number="masterLogLevel"
|
||||
:disabled="busy || !state.uart_connected">
|
||||
<option value="0">None (aus)</option>
|
||||
<option value="1">Error</option>
|
||||
<option value="2">Warn</option>
|
||||
<option value="3">Info</option>
|
||||
<option value="4">Debug</option>
|
||||
<option value="5">Verbose</option>
|
||||
</select>
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm"
|
||||
@click="readMasterLogLevel()"
|
||||
:disabled="busy || !state.uart_connected">
|
||||
Lesen
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary btn-sm"
|
||||
@click="setMasterLogLevel()"
|
||||
:disabled="busy || !state.uart_connected">
|
||||
Setzen
|
||||
</button>
|
||||
</div>
|
||||
<p class="text-muted small mt-2 mb-0" x-show="!state.uart_connected">
|
||||
UART nicht verbunden — Eingabe gesperrt.
|
||||
</p>
|
||||
@@ -627,6 +654,7 @@
|
||||
ws: null,
|
||||
wsConnected: false,
|
||||
masterDz: 100,
|
||||
masterLogLevel: 0,
|
||||
allDz: 100,
|
||||
allTapSingle: false,
|
||||
allTapDouble: false,
|
||||
@@ -766,6 +794,11 @@
|
||||
if (data.samples?.length) this.applyBatterySamples(data.samples);
|
||||
} catch (_) {}
|
||||
},
|
||||
formatLogLevel(level) {
|
||||
const labels = ['None', 'Error', 'Warn', 'Info', 'Debug', 'Verbose'];
|
||||
if (level == null || level < 0 || level > 5) return '—';
|
||||
return `${labels[level]} (${level})`;
|
||||
},
|
||||
formatMac(hex) {
|
||||
if (!hex || hex.length !== 12) return hex || '';
|
||||
return hex.match(/.{2}/g).join(':');
|
||||
@@ -1104,6 +1137,44 @@
|
||||
async setMasterDeadzone() {
|
||||
await this.setDeadzone(0, this.masterDz);
|
||||
},
|
||||
async readMasterLogLevel() {
|
||||
this.busy = true;
|
||||
try {
|
||||
const r = await fetch('/api/log-level');
|
||||
const data = await r.json();
|
||||
if (!r.ok || !data.success) {
|
||||
this.flash(data.error || 'Log-Level lesen fehlgeschlagen', false);
|
||||
return;
|
||||
}
|
||||
this.masterLogLevel = data.level;
|
||||
this.flash(`Master: Log-Level ${this.formatLogLevel(data.level)}`, true);
|
||||
} catch (e) {
|
||||
this.flash(String(e), false);
|
||||
} finally {
|
||||
this.busy = false;
|
||||
}
|
||||
},
|
||||
async setMasterLogLevel() {
|
||||
this.busy = true;
|
||||
try {
|
||||
const r = await fetch('/api/log-level', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ write: true, level: this.masterLogLevel })
|
||||
});
|
||||
const data = await r.json();
|
||||
if (!r.ok || !data.success) {
|
||||
this.flash(data.error || 'Log-Level setzen fehlgeschlagen', false);
|
||||
return;
|
||||
}
|
||||
this.masterLogLevel = data.level;
|
||||
this.flash(`Master: Log-Level ${this.formatLogLevel(data.level)} gesetzt`, true);
|
||||
} catch (e) {
|
||||
this.flash(String(e), false);
|
||||
} finally {
|
||||
this.busy = false;
|
||||
}
|
||||
},
|
||||
patchLiveStream(enabled) {
|
||||
let clients = this.state.clients || [];
|
||||
if (!enabled) {
|
||||
|
||||
Reference in New Issue
Block a user