MCPcopy Index your code
hub / github.com/nodejs/node / load

Method load

deps/npm/lib/utils/log-file.js:49–87  ·  view source on GitHub ↗
({ command, path, logsMax = Infinity, timing } = {})

Source from the content-addressed store, hash-verified

47 }
48
49 load ({ command, path, logsMax = Infinity, timing } = {}) {
50 if (['completion'].includes(command)) {
51 return
52 }
53
54 // dir is user configurable and is required to exist so this can error if the dir is missing or not configured correctly
55 this.#path = path
56 this.#logsMax = logsMax
57 this.#timing = timing
58
59 // Log stream has already ended
60 if (!this.#logStream) {
61 return
62 }
63
64 log.verbose('logfile', `logs-max:${logsMax} dir:${this.#path}`)
65
66 // Write the contents of our array buffer to our new file stream and set that as the new log logstream for future writes
67 // if logs max is 0 then the user does not want a log file
68 if (this.#logsMax > 0) {
69 const initialFile = this.#openLogFile()
70 if (initialFile) {
71 for (const item of this.#logStream) {
72 const formatted = this.#formatLogItem(...item)
73 if (formatted !== null) {
74 initialFile.write(formatted)
75 }
76 }
77 this.#logStream = initialFile
78 }
79 }
80
81 log.verbose('logfile', this.files[0] || 'no logfile created')
82
83 // Kickoff cleaning process, even if we aren't writing a logfile.
84 // This is async but it will always ignore the current logfile
85 // Return the result so it can be awaited in tests
86 return this.#cleanLogs()
87 }
88
89 get files () {
90 return this.#files

Callers

nothing calls this directly

Calls 6

#openLogFileMethod · 0.95
#formatLogItemMethod · 0.95
#cleanLogsMethod · 0.95
includesMethod · 0.80
verboseMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected