mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-11-09 17:06:13 -06:00
- Add `getRequiredEnv()`: replaces all `process.env.X || 'default'` fallbacks with a hard throw so a missing or typo'd .env key fails immediately with a diagnostic message instead of silently operating on wrong defaults - Add `logSetup.js`: dual-transport logging — console filtered by $DEBUG, plus a full debug-level file in /tmp for post-mortem inspection - Add `assertRepositoryMatchesConfig()`: fails fast when a named repository in XO points at a different path than the one declared in .env - Make `getAllowedCleanupPaths()` lazy so env vars are read after .env is loaded, not at ESM module evaluation time - Pass full error objects (not `.message`) to all structured log calls - Add retry logic on flaky operations and surface more detail on failures - Fix: only purge non-empty backup repositories - Fix: backup jobs no longer skipped under some conditions - Fix: missing `backuprepository.delete` function - Add `.USAGE.md` and update `README.md`
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
import { createWriteStream } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import { inspect } from 'node:util'
|
|
import transportConsole from '@xen-orchestra/log/transports/console'
|
|
import { configure } from '@xen-orchestra/log/configure'
|
|
|
|
const logFile = join(tmpdir(), `xo-qa-test-${Date.now()}.log`)
|
|
const logStream = createWriteStream(logFile)
|
|
process.stderr.write(`[qa-test] debug log: ${logFile}\n`)
|
|
|
|
const LEVEL_NAMES = { 20: 'DEBUG', 30: 'INFO', 40: 'WARN', 50: 'ERROR', 60: 'FATAL' }
|
|
|
|
const fileTransport = ({ data, level, namespace, message, time }) => {
|
|
const levelName = (LEVEL_NAMES[level] ?? String(level)).padEnd(5)
|
|
const dataStr = data != null ? ' ' + inspect(data, { depth: 3, breakLength: Infinity, compact: true }) : ''
|
|
logStream.write(`${time.toISOString()} ${levelName} ${namespace.padEnd(28)} ${message}${dataStr}\n`)
|
|
}
|
|
|
|
configure([
|
|
{
|
|
filter: process.env.DEBUG,
|
|
level: process.env.DEBUG_LEVEL ?? 'info',
|
|
transport: transportConsole(),
|
|
},
|
|
{
|
|
level: 'debug', // capture everything
|
|
transport: fileTransport,
|
|
},
|
|
])
|