MCPcopy
hub / github.com/desktop/desktop / log

Method log

app/src/main-process/desktop-file-transport.ts:47–73  ·  view source on GitHub ↗
(info: any, callback: () => void)

Source from the content-addressed store, hash-verified

45 }
46
47 public async log(info: any, callback: () => void) {
48 const path = getFilePath(this.logDirectory)
49
50 if (this.stream === undefined || this.stream.path !== path) {
51 if (this.stream !== undefined) {
52 await promisify(this.stream.end).call(this.stream).catch(error('end'))
53 await promisify(this.stream.close)
54 .call(this.stream)
55 .catch(error('close'))
56 }
57 const stream = (this.stream = createWriteStream(path, { flags: 'a' }))
58
59 await new Promise((resolve, reject) => {
60 stream.on('open', resolve)
61 stream.on('error', reject)
62 }).catch(error('stream error'))
63
64 await pruneDirectory(this.logDirectory).catch(error('prune'))
65 }
66
67 if (this.stream !== undefined) {
68 await write(this.stream, `${info[MESSAGE]}${EOL}`).catch(error('write'))
69 this.emit('logged', info)
70 }
71
72 callback?.()
73 }
74
75 public close(cb?: () => void) {
76 this.stream?.end(cb)

Callers 15

test-setup.tsFile · 0.45
start.tsFile · 0.45
validateMacOSVersionFunction · 0.45
package.tsFile · 0.45
packageOSXFunction · 0.45
packageWindowsFunction · 0.45
build.tsFile · 0.45
copyDependenciesFunction · 0.45

Calls 6

getFilePathFunction · 0.85
pruneDirectoryFunction · 0.85
writeFunction · 0.85
errorFunction · 0.70
onMethod · 0.65
emitMethod · 0.65

Tested by

no test coverage detected