Allow continusously printing logs through tail and parse-log

pull/5215/head
Florent 2022-08-16 08:06:49 +02:00 committed by Chocobozzz
parent cbdbee807d
commit 045224d5eb
3 changed files with 18 additions and 4 deletions

View File

@ -7,11 +7,11 @@ root = true
end_of_line = lf end_of_line = lf
charset = utf-8 charset = utf-8
[*.yml] [*.{yml,html}]
indent_style = space indent_style = space
indent_size = 2 indent_size = 2
[{client,server,shared}/**.{ts,json,js}] [{client,server,shared,scripts}/**.{ts,json,js}]
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
indent_style = space indent_style = space

View File

@ -1,6 +1,7 @@
import { program } from 'commander' import { program } from 'commander'
import { createReadStream, readdir } from 'fs-extra' import { createReadStream, readdir } from 'fs-extra'
import { join } from 'path' import { join } from 'path'
import { stdin } from 'process'
import { createInterface } from 'readline' import { createInterface } from 'readline'
import { format as sqlFormat } from 'sql-formatter' import { format as sqlFormat } from 'sql-formatter'
import { inspect } from 'util' import { inspect } from 'util'
@ -89,7 +90,7 @@ async function run () {
function readFile (file: string) { function readFile (file: string) {
console.log('Opening %s.', file) console.log('Opening %s.', file)
const stream = createReadStream(file) const stream = file === '-' ? stdin : createReadStream(file)
const rl = createInterface({ const rl = createInterface({
input: stream input: stream
@ -117,7 +118,7 @@ function readFile (file: string) {
} }
}) })
stream.once('close', () => res()) stream.once('end', () => res())
}) })
} }

View File

@ -79,6 +79,19 @@ While testing, you might want to display a server's logs to understand why they
NODE_APP_INSTANCE=1 NODE_ENV=test npm run parse-log -- --level debug | less +GF NODE_APP_INSTANCE=1 NODE_ENV=test npm run parse-log -- --level debug | less +GF
``` ```
You can also:
- checkout only the latest logs (PeerTube >= 5.0):
```bash
tail -n 100 test1/logs/peertube.log | npm run parse-log -- --level debug --files -
```
- continuously print the latests logs (PeerTube >= 5.0):
```bash
tail -f test1/logs/peertube.log | npm run parse-log -- --level debug --files -
```
## Client E2E tests ## Client E2E tests