Merge pull request #168 from yxc0915/codex/fix-precision-log-severity
fix(logs): 修正 QEMU 精度提示误报为错误
This commit is contained in:
4 files changed
+49
-8
No files matched your search
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"group": "fixes",
|
||||
"order": 0,
|
||||
"authors": ["yxc0915"],
|
||||
"zh": "修复 QEMU 的 Metal 精度提示误标为错误,避免这些提示增加未读错误计数。",
|
||||
"en": "Show QEMU Metal precision notes as informational logs so they do not increase the unread error count."
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { loadTestModule } from './load-test-module.mjs'
|
||||
|
||||
const { createLogLine } = await loadTestModule(`export * from './lib/logs'`)
|
||||
|
||||
const renderSelector = 'newRenderPipelineStateWithDescriptor:error:'
|
||||
const computeSelector = 'newComputePipelineStateWithDescriptor:options:reflection:error:'
|
||||
const precisionNote = (selector, code) =>
|
||||
`[QEMU] reims-vgpu: ${selector}: metal2vulkan-runtime made it with a precision note (metal2vulkan-degrade-${code}): its answers there can differ from Metal's on this device; the first of its kind, each make that carries it counted`
|
||||
|
||||
test('successful render and compute precision notes keep their text as informational logs', () => {
|
||||
for (const line of [
|
||||
precisionNote(renderSelector, 'device-denormals'),
|
||||
precisionNote(computeSelector, 'simdgroup-access-order'),
|
||||
]) {
|
||||
const row = createLogLine({ line })
|
||||
assert.equal(row.level, 'info')
|
||||
assert.equal(row.line, line)
|
||||
}
|
||||
})
|
||||
|
||||
test('pipeline refusals and fatal errors retain their error level', () => {
|
||||
for (const line of [
|
||||
`[QEMU] reims-vgpu: platform call ${renderSelector}: the runtime refused it`,
|
||||
'[QEMU] reims-vgpu: fatal: Vulkan device was lost',
|
||||
`${precisionNote(renderSelector, 'device-denormals')}; error: failed to submit the command buffer`,
|
||||
]) {
|
||||
assert.equal(createLogLine({ line }).level, 'error')
|
||||
}
|
||||
})
|
||||
@@ -16,7 +16,7 @@ import { buildFallbackChain, I18nKey, localeDir, locText, parseAppError, resolve
|
||||
import { defaultGuestLang, recommendedMemoryGB, recommendedResolution } from './lib/format'
|
||||
import { isMacOSDriver, liveVMInfo, splitEndpoints, vmFeatures } from './lib/endpoints'
|
||||
import { resolveFullscreenHotkey } from './lib/fullscreenHotkey'
|
||||
import { LogLine, appendLog } from './lib/logs'
|
||||
import { LogLine, appendLog, createLogLine } from './lib/logs'
|
||||
import { macOSMajor } from './macos/macosRelease'
|
||||
import { currentTask, finishedTaskTTL, isActiveInstallerTask, pruneFinishedTasks, upsertTask } from './lib/tasks'
|
||||
import { applyActiveLocaleFonts, applyActiveTheme, disposeActiveThemeAndLocaleFonts, notifyInteractiveThemeState } from './lib/themeEngine'
|
||||
@@ -200,11 +200,11 @@ export const App: React.FC = () => {
|
||||
// Logs never pop the panel open (see docs/design-guidelines.md); errors only bump a badge.
|
||||
const offLog = events.onLog((entry) => {
|
||||
if (!entry || typeof entry !== 'object') return
|
||||
const lineText = typeof entry.line === 'string' ? entry.line : String(entry.line ?? '')
|
||||
if (!logsOpenRef.current && /\b(error|failed|fatal|panic)\b/i.test(lineText)) {
|
||||
const line = createLogLine(entry)
|
||||
if (!logsOpenRef.current && line.level === 'error') {
|
||||
setUnseenErrors((n) => n + 1)
|
||||
}
|
||||
setLogLines((prev) => appendLog(prev, entry))
|
||||
setLogLines((prev) => appendLog(prev, line))
|
||||
})
|
||||
// Tasks: seed from the backend, then follow events.
|
||||
api.GetTasks().then((list) => {
|
||||
|
||||
@@ -14,18 +14,21 @@ const MAX_LOG_LINES = 2000
|
||||
// backend tags them explicitly.
|
||||
const ERROR_RE = /\b(error|failed|fatal|panic)\b/i
|
||||
const WARN_RE = /\bwarn(ing)?\b/i
|
||||
// Successful vGPU precision notes include the Metal selector's error: argument.
|
||||
const PRECISION_NOTE_PREFIX = /^(?:\[QEMU\] )?reims-vgpu: [\w:]+: metal2vulkan-runtime made it with a precision note \(metal2vulkan-degrade-[a-z0-9-]+\): /
|
||||
|
||||
let nextId = 1
|
||||
|
||||
function classify(entry: LogEntry): LogLine {
|
||||
export function createLogLine(entry: LogEntry): LogLine {
|
||||
const ts = typeof entry?.ts === 'string' ? entry.ts : ''
|
||||
const source = typeof entry?.source === 'string' ? entry.source : ''
|
||||
const line = typeof entry?.line === 'string' ? entry.line : String(entry?.line ?? '')
|
||||
const level: LogLevel = ERROR_RE.test(line) ? 'error' : WARN_RE.test(line) ? 'warn' : 'info'
|
||||
const message = line.replace(PRECISION_NOTE_PREFIX, '')
|
||||
const level: LogLevel = ERROR_RE.test(message) ? 'error' : WARN_RE.test(message) ? 'warn' : 'info'
|
||||
return { ts, source, line, id: nextId++, level }
|
||||
}
|
||||
|
||||
export function appendLog(prev: LogLine[], entry: LogEntry): LogLine[] {
|
||||
const next = [...prev, classify(entry)]
|
||||
export function appendLog(prev: LogLine[], line: LogLine): LogLine[] {
|
||||
const next = [...prev, line]
|
||||
return next.length > MAX_LOG_LINES ? next.slice(next.length - MAX_LOG_LINES) : next
|
||||
}
|
||||
Reference in new issue
Block a user