Fix log parser with multiple files
This commit is contained in:
parent
f686f5ed0a
commit
5220859984
|
@ -76,13 +76,17 @@ run()
|
|||
.then(() => process.exit(0))
|
||||
.catch(err => console.error(err))
|
||||
|
||||
function run () {
|
||||
return new Promise<void>(async res => {
|
||||
async function run () {
|
||||
const files = await getFiles()
|
||||
|
||||
for (const file of files) {
|
||||
if (file === 'peertube-audit.log') continue
|
||||
|
||||
await readFile(file)
|
||||
}
|
||||
}
|
||||
|
||||
function readFile (file: string) {
|
||||
console.log('Opening %s.', file)
|
||||
|
||||
const stream = createReadStream(file)
|
||||
|
@ -91,6 +95,7 @@ function run () {
|
|||
input: stream
|
||||
})
|
||||
|
||||
return new Promise<void>(res => {
|
||||
rl.on('line', line => {
|
||||
try {
|
||||
const log = JSON.parse(line)
|
||||
|
@ -113,7 +118,6 @@ function run () {
|
|||
})
|
||||
|
||||
stream.once('close', () => res())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue