MCPcopy Create free account
hub / github.com/chakra-ui/panda / setLogStream

Function setLogStream

packages/node/src/logstream.ts:10–40  ·  view source on GitHub ↗
(options: LogstreamOptions)

Source from the content-addressed store, hash-verified

8}
9
10export const setLogStream = (options: LogstreamOptions) => {
11 const { cwd = process.cwd() } = options
12
13 let stream: fs.WriteStream | undefined
14
15 if (options.logfile) {
16 const outPath = path.resolve(cwd, options.logfile)
17
18 ensure(outPath)
19 logger.info('logfile', outPath)
20
21 stream = fs.createWriteStream(outPath, { flags: 'a' })
22
23 logger.onLog = (entry) => {
24 stream?.write(JSON.stringify(entry) + '\n')
25 }
26 }
27
28 process.once('SIGINT', () => {
29 stream?.end()
30 })
31
32 return {
33 end() {
34 stream?.end()
35 },
36 [Symbol.dispose]: () => {
37 stream?.end()
38 },
39 }
40}
41
42const ensure = (outPath: string) => {
43 const dirname = path.dirname(outPath)

Callers 2

pandacssFunction · 0.90
mainFunction · 0.90

Calls 3

ensureFunction · 0.85
cwdMethod · 0.65
resolveMethod · 0.65

Tested by

no test coverage detected