MCPcopy Create free account
hub / github.com/nodejs/node / #writeLog

Method #writeLog

deps/npm/lib/utils/display.js:415–443  ·  view source on GitHub ↗
(level, meta, ...args)

Source from the content-addressed store, hash-verified

413 }
414
415 #writeLog (level, meta, ...args) {
416 const levelOpts = LEVEL_METHODS[level]
417 const show = levelOpts.show ?? (({ index }) => levelOpts.index <= index)
418 const force = meta.force && !this.#silent
419
420 if (force || show({ index: this.#levelIndex, timing: this.#timing })) {
421 // this mutates the array so we can pass args directly to format later
422 const title = args.shift()
423 const prefix = [
424 this.#logColors.heading(this.#heading),
425 this.#logColors[level](level),
426 title ? this.#logColors.title(title) : null,
427 ]
428 const writeOpts = { prefix }
429 // notice logs typically come from `npm-notice` headers in responses. Some of them have 2fa login links so we skip redaction.
430 if (level === 'notice') {
431 writeOpts.redact = false
432 // Deduplicate notices within a single command execution, unless in verbose mode
433 if (this.#levelIndex < LEVEL_OPTIONS.verbose.index) {
434 const noticeKey = JSON.stringify([title, ...args])
435 if (this.#seenNotices.has(noticeKey)) {
436 return
437 }
438 this.#seenNotices.add(noticeKey)
439 }
440 }
441 this.#write(this.#stderr, writeOpts, ...args)
442 }
443 }
444}
445
446class Progress {

Callers 1

#tryWriteLogMethod · 0.95

Calls 6

#writeMethod · 0.95
showFunction · 0.85
hasMethod · 0.65
addMethod · 0.65
shiftMethod · 0.45
titleMethod · 0.45

Tested by

no test coverage detected