| 390 | // LOGS |
| 391 | |
| 392 | #tryWriteLog (level, meta, ...args) { |
| 393 | try { |
| 394 | // Also (and this is a really inexcusable kludge), we patch the log.warn() method so that when we see a peerDep override explanation from Arborist, we can replace the object with a highly abbreviated explanation of what's being overridden. |
| 395 | // TODO: this could probably be moved to arborist now that display is refactored |
| 396 | const [heading, message, expl] = args |
| 397 | if (level === log.KEYS.warn && heading === 'ERESOLVE' && expl && typeof expl === 'object') { |
| 398 | this.#writeLog(level, meta, heading, message) |
| 399 | this.#writeLog(level, meta, '', explain(expl, this.#stderrChalk, 2)) |
| 400 | return |
| 401 | } |
| 402 | this.#writeLog(level, meta, ...args) |
| 403 | } catch (ex) { |
| 404 | try { |
| 405 | // if it crashed once, it might again! |
| 406 | this.#writeLog(log.KEYS.verbose, meta, '', `attempt to log crashed`, ...args, ex) |
| 407 | } catch (ex2) { |
| 408 | // This happens if the object has an inspect method that crashes so just console.error with the errors but don't do anything else that might error again. |
| 409 | // eslint-disable-next-line no-console |
| 410 | console.error(`attempt to log crashed`, ex, ex2) |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | #writeLog (level, meta, ...args) { |
| 416 | const levelOpts = LEVEL_METHODS[level] |