🎥 Make videos programmatically with React
logging verbose
Jonny Burger44a13c2ff67e
diff --git a/packages/cli/src/compositions.ts b/packages/cli/src/compositions.tsindex 2d10194816..742f2beb7a 100644--- a/packages/cli/src/compositions.ts+++ b/packages/cli/src/compositions.ts@@ -74,5 +74,5 @@ export const listCompositionsCommand = async (await RenderInternals.cleanDownloadMap(downloadMap);await cleanupBundle();- Log.verbose('Cleaned up', downloadMap.assetDir);+ Log.verboseIndent(true, 'Cleaned up', downloadMap.assetDir);};diff --git a/packages/cli/src/log.ts b/packages/cli/src/log.tsindex 6ed79bb9b8..6ab08cdea8 100644--- a/packages/cli/src/log.ts+++ b/packages/cli/src/log.ts@@ -17,6 +17,12 @@ export const Log = {return console.log(...args.map((a) => chalk.blueBright(a)));}},+ verboseIndent: (indent: boolean, ...args: Parameters<typeof console.log>) => {+ Log.verbose(+ ...[indent ? chalk.gray(INDENT_TOKEN) : null, ...args].filter(truthy)+ );+ },+info: (...args: Parameters<typeof console.log>) => {if (RenderInternals.isEqualOrBelowLogLevel(diff --git a/packages/cli/src/render-flows/still.ts b/packages/cli/src/render-flows/still.tsindex a1eb28e0b9..c086a93e4c 100644--- a/packages/cli/src/render-flows/still.ts+++ b/packages/cli/src/render-flows/still.ts@@ -22,7 +22,7 @@ import {chalk} from '../chalk';import {determineFinalImageFormat} from '../determine-image-format';import {getAndValidateAbsoluteOutputFile} from '../get-cli-options';import {getCompositionWithDimensionOverride} from '../get-composition-with-dimension-override';-import {Log} from '../log';+import {INDENT_TOKEN, Log} from '../log';import {parsedCli, quietFlagProvided} from '../parse-command-line';import type {JobProgressCallback} from '../preview-server/render-queue/job';import type {@@ -120,7 +120,7 @@ export const renderStillFlow = async ({onProgress({progress, message});};- Log.verbose('Browser executable: ', browserExecutable);+ Log.verboseIndent(indentOutput, 'Browser executable: ', browserExecutable);const shouldDumpIo = RenderInternals.isEqualOrBelowLogLevel(logLevel,'verbose'@@ -131,6 +131,7 @@ export const renderStillFlow = async ({chromiumOptions,shouldDumpIo,forceDeviceScaleFactor: scale,+ indentationString: chalk.gray(INDENT_TOKEN + ' '),});const steps: RenderStep[] = [@@ -262,6 +263,7 @@ export const renderStillFlow = async ({onDownload,port,downloadMap,+ puppeteerInstance,});aggregate.rendering = {@@ -272,7 +274,7 @@ export const renderStillFlow = async ({totalFrames: 1,};updateProgress();- Log.info();+ Log.infoIndent(indentOutput);const closeBrowserPromise = puppeteerInstance.close(false);@@ -281,5 +283,5 @@ export const renderStillFlow = async ({await RenderInternals.cleanDownloadMap(downloadMap);await cleanupBundle();- Log.verbose(indentOutput, 'Cleaned up', downloadMap.assetDir);+ Log.verboseIndent(indentOutput, 'Cleaned up', downloadMap.assetDir);};diff --git a/packages/cli/src/setup-cache.ts b/packages/cli/src/setup-cache.tsindex f87b133ad7..e11803c136 100644--- a/packages/cli/src/setup-cache.ts+++ b/packages/cli/src/setup-cache.ts@@ -147,12 +147,15 @@ export const bundleOnCli = async ({hash);if (cacheExistedBefore !== 'does-not-exist' && !shouldCache) {- Log.info('🧹 Cache disabled but found. Deleting... ');+ Log.infoIndent(indentOutput, '🧹 Cache disabled but found. Deleting... ');await BundlerInternals.clearCache(remotionRoot);}if (cacheExistedBefore === 'other-exists' && shouldCache) {- Log.info('🧹 Webpack config change detected. Clearing cache... ');+ Log.infoIndent(+ indentOutput,+ '🧹 Webpack config change detected. Clearing cache... '+ );await BundlerInternals.clearCache(remotionRoot);}@@ -192,7 +195,7 @@ export const bundleOnCli = async ({};updateProgress(true);- Log.verbose('Bundled under', bundled);+ Log.verboseIndent(indentOutput, 'Bundled under', bundled);const cacheExistedAfter =BundlerInternals.cacheExists(remotionRoot, 'production', hash) === 'exists';@@ -201,7 +204,10 @@ export const bundleOnCli = async ({cacheExistedBefore === 'does-not-exist' ||cacheExistedBefore === 'other-exists') {- Log.info('⚡️ Cached bundle. Subsequent renders will be faster.');+ Log.infoIndent(+ indentOutput,+ '⚡️ Cached bundle. Subsequent renders will be faster.'+ );}}diff --git a/packages/renderer/src/browser/BrowserRunner.ts b/packages/renderer/src/browser/BrowserRunner.tsindex 74a397069c..145007d862 100644--- a/packages/renderer/src/browser/BrowserRunner.ts+++ b/packages/renderer/src/browser/BrowserRunner.ts@@ -36,6 +36,8 @@ const PROCESS_ERROR_EXPLANATION = `Puppeteer was unable to kill the process whicPlease check your open processes and ensure that the browser processes that Puppeteer launched have been killed.If you think this is a bug, please report it on the Puppeteer issue tracker.`;+export const INDENT_TOKEN = '│';+export class BrowserRunner {#executablePath: string;#processArguments: string[];@@ -91,8 +93,14 @@ export class BrowserRunner {});if (dumpio) {- this.proc.stderr?.pipe(process.stderr);- this.proc.stdout?.pipe(process.stdout);+ this.proc.stdout?.on('data', (d) => {+ process.stdout.write(options.indentationString);+ process.stdout.write(d.toString().trimStart());+ });+ this.proc.stderr?.on('data', (d) => {+ process.stderr.write(options.indentationString);+ process.stderr.write(d.toString().trimStart());+ });}this.#closed = false;diff --git a/packages/renderer/src/browser/LaunchOptions.ts b/packages/renderer/src/browser/LaunchOptions.tsindex ac4a4c5a70..e7f8725a87 100644--- a/packages/renderer/src/browser/LaunchOptions.ts+++ b/packages/renderer/src/browser/LaunchOptions.ts@@ -32,6 +32,7 @@ export interface LaunchOptions {env?: Record<string, string | undefined>;pipe?: boolean;product?: Product;+ indentationString: string;}export type PuppeteerNodeLaunchOptions = BrowserLaunchArgumentOptions &diff --git a/packages/renderer/src/browser/Launcher.ts b/packages/renderer/src/browser/Launcher.tsindex 32d01f5f08..9278ac3288 100644--- a/packages/renderer/src/browser/Launcher.ts+++ b/packages/renderer/src/browser/Launcher.ts@@ -55,6 +55,7 @@ export class ChromeLauncher implements ProductLauncher {defaultViewport,timeout = 60000,debuggingPort,+ indentationString,} = options;const chromeArguments = args;@@ -101,6 +102,7 @@ export class ChromeLauncher implements ProductLauncher {dumpio,env,pipe: false,+ indentationString,});let browser;diff --git a/packages/renderer/src/open-browser.ts b/packages/renderer/src/open-browser.tsindex da6c889ba9..53bb7630f9 100644--- a/packages/renderer/src/open-browser.ts+++ b/packages/renderer/src/open-browser.ts@@ -55,6 +55,7 @@ export const openBrowser = async (chromiumOptions?: ChromiumOptions;forceDeviceScaleFactor?: number;viewport?: Viewport;+ indentationString?: string;}): Promise<PuppeteerBrowser> => {if (browser === 'firefox') {@@ -78,6 +79,7 @@ export const openBrowser = async (executablePath,product: browser,dumpio: options?.shouldDumpIo ?? false,+ indentationString: options?.indentationString ?? '',args: ['about:blank','--allow-pre-commit-input',