From 045224d5eb6a41081186c4040bab1570b9d9ad65 Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 16 Aug 2022 08:06:49 +0200 Subject: [PATCH] Allow continusously printing logs through tail and parse-log --- .editorconfig | 4 ++-- scripts/parse-log.ts | 5 +++-- support/doc/development/tests.md | 13 +++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.editorconfig b/.editorconfig index b7d3033f3..843d5d926 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,11 +7,11 @@ root = true end_of_line = lf charset = utf-8 -[*.yml] +[*.{yml,html}] indent_style = space indent_size = 2 -[{client,server,shared}/**.{ts,json,js}] +[{client,server,shared,scripts}/**.{ts,json,js}] trim_trailing_whitespace = true insert_final_newline = true indent_style = space diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts index 5a420a46c..6770f090b 100755 --- a/scripts/parse-log.ts +++ b/scripts/parse-log.ts @@ -1,6 +1,7 @@ import { program } from 'commander' import { createReadStream, readdir } from 'fs-extra' import { join } from 'path' +import { stdin } from 'process' import { createInterface } from 'readline' import { format as sqlFormat } from 'sql-formatter' import { inspect } from 'util' @@ -89,7 +90,7 @@ async function run () { function readFile (file: string) { console.log('Opening %s.', file) - const stream = createReadStream(file) + const stream = file === '-' ? stdin : createReadStream(file) const rl = createInterface({ input: stream @@ -117,7 +118,7 @@ function readFile (file: string) { } }) - stream.once('close', () => res()) + stream.once('end', () => res()) }) } diff --git a/support/doc/development/tests.md b/support/doc/development/tests.md index 52e7993b2..207d4f984 100644 --- a/support/doc/development/tests.md +++ b/support/doc/development/tests.md @@ -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 ``` +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