Skip to content

🎥 Make videos programmatically with React

verbose logging toggle

Jonny Burger7ba0bf57f876
diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.ts
index a092604fcd..d6871a3c5f 100644
--- a/packages/cli/src/benchmark.ts
+++ b/packages/cli/src/benchmark.ts
@@ -190,6 +190,7 @@ export const benchmarkCommand = async (
steps: ['bundling'],
onProgress: () => undefined,
indentOutput: false,
+ logLevel: ConfigInternals.Logging.getLogLevel(),
});
const puppeteerInstance = await browserInstance;
diff --git a/packages/cli/src/compositions.ts b/packages/cli/src/compositions.ts
index 742f2beb7a..53c460d0d8 100644
--- a/packages/cli/src/compositions.ts
+++ b/packages/cli/src/compositions.ts
@@ -1,4 +1,5 @@
import {getCompositions, RenderInternals} from '@remotion/renderer';
+import {ConfigInternals} from './config';
import {convertEntryPointToServeUrl} from './convert-entry-point-to-serve-url';
import {findEntryPoint} from './entry-point';
import {getCliOptions} from './get-cli-options';
@@ -56,6 +57,7 @@ export const listCompositionsCommand = async (
publicDir,
onProgress: () => undefined,
indentOutput: false,
+ logLevel: ConfigInternals.Logging.getLogLevel(),
});
const compositions = await getCompositions(bundled, {
@@ -74,5 +76,5 @@ export const listCompositionsCommand = async (
await RenderInternals.cleanDownloadMap(downloadMap);
await cleanupBundle();
- Log.verboseIndent(true, 'Cleaned up', downloadMap.assetDir);
+ Log.verbose('Cleaned up', downloadMap.assetDir);
};
diff --git a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx b/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
index aa5aaca0f5..eeb7a0193b 100644
--- a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
+++ b/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
@@ -1,5 +1,5 @@
import type {StillImageFormat} from '@remotion/renderer';
-import type {ChangeEventHandler} from 'react';
+import type {ChangeEvent, ChangeEventHandler} from 'react';
import React, {
useCallback,
useContext,
@@ -140,6 +140,7 @@ export const RenderModal: React.FC<{composition: TCompMetadata}> = ({
const [imageFormat, setImageFormat] = useState<StillImageFormat>('png');
const [quality, setQuality] = useState(80);
const [scale, setScale] = useState(1);
+ const [verbose, setVerboseLogging] = useState(false);
const [outName, setOutName] = useState(() =>
getDefaultOutLocation({
compositionName: composition.id,
@@ -191,6 +192,7 @@ export const RenderModal: React.FC<{composition: TCompMetadata}> = ({
// TODO: Support still rendering for compositions
frame: 0,
scale,
+ verbose,
})
.then(() => {
dispatchIfMounted({type: 'succeed'});
@@ -207,6 +209,7 @@ export const RenderModal: React.FC<{composition: TCompMetadata}> = ({
quality,
scale,
setSelectedModal,
+ verbose,
]);
const onQualityChangedDirectly = useCallback((newQuality: number) => {
@@ -278,6 +281,13 @@ export const RenderModal: React.FC<{composition: TCompMetadata}> = ({
];
}, [imageFormat, setJpeg, setPng]);
+ const onVerboseLoggingChanged = useCallback(
+ (e: ChangeEvent<HTMLInputElement>) => {
+ setVerboseLogging(e.target.checked);
+ },
+ []
+ );
+
return (
<ModalContainer onOutsideClick={onQuit} onEscape={onQuit}>
<NewCompHeader title={`Render ${composition.id}`} />
@@ -331,6 +341,16 @@ export const RenderModal: React.FC<{composition: TCompMetadata}> = ({
/>
</div>
</div>
+ <div style={optionRow}>
+ <div style={label}>Verbose logging</div>
+ <div style={rightRow}>
+ <input
+ type={'checkbox'}
+ checked={verbose}
+ onChange={onVerboseLoggingChanged}
+ />
+ </div>
+ </div>
{imageFormat === 'jpeg' && (
<div style={optionRow}>
<div style={label}>JPEG Quality</div>
diff --git a/packages/cli/src/editor/components/RenderQueue/actions.ts b/packages/cli/src/editor/components/RenderQueue/actions.ts
index c62c0c3092..eb883e09bb 100644
--- a/packages/cli/src/editor/components/RenderQueue/actions.ts
+++ b/packages/cli/src/editor/components/RenderQueue/actions.ts
@@ -45,6 +45,7 @@ export const addStillRenderJob = ({
quality,
frame,
scale,
+ verbose,
}: {
composition: TCompMetadata;
outName: string;
@@ -52,6 +53,7 @@ export const addStillRenderJob = ({
quality: number | null;
frame: number;
scale: number;
+ verbose: boolean;
}) => {
return callApi('/api/render', {
compositionId: composition.id,
@@ -61,6 +63,7 @@ export const addStillRenderJob = ({
quality,
frame,
scale,
+ verbose,
});
};
diff --git a/packages/cli/src/log.ts b/packages/cli/src/log.ts
index 6ab08cdea8..a4d1fa6f45 100644
--- a/packages/cli/src/log.ts
+++ b/packages/cli/src/log.ts
@@ -1,4 +1,5 @@
/* eslint-disable no-console */
+import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import {chalk} from './chalk';
import {ConfigInternals} from './config';
@@ -17,12 +18,18 @@ 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)
- );
+ verboseAdvanced: (
+ options: {indent: boolean; logLevel: LogLevel},
+ ...args: Parameters<typeof console.log>
+ ) => {
+ if (RenderInternals.isEqualOrBelowLogLevel(options.logLevel, 'verbose')) {
+ return console.log(
+ ...[options.indent ? chalk.gray(INDENT_TOKEN) : null, ...args].filter(
+ truthy
+ )
+ );
+ }
},
-
info: (...args: Parameters<typeof console.log>) => {
if (
RenderInternals.isEqualOrBelowLogLevel(
@@ -33,10 +40,17 @@ export const Log = {
return console.log(...args);
}
},
- infoIndent: (indent: boolean, ...args: Parameters<typeof console.log>) => {
- Log.info(
- ...[indent ? chalk.gray(INDENT_TOKEN) : null, ...args].filter(truthy)
- );
+ infoAdvanced: (
+ options: {indent: boolean; logLevel: LogLevel},
+ ...args: Parameters<typeof console.log>
+ ) => {
+ if (RenderInternals.isEqualOrBelowLogLevel(options.logLevel, 'info')) {
+ return console.log(
+ ...[options.indent ? chalk.gray(INDENT_TOKEN) : null, ...args].filter(
+ truthy
+ )
+ );
+ }
},
warn: (...args: Parameters<typeof console.log>) => {
if (
diff --git a/packages/cli/src/preview-server/render-queue/job.ts b/packages/cli/src/preview-server/render-queue/job.ts
index e0100c09ed..245fc78017 100644
--- a/packages/cli/src/preview-server/render-queue/job.ts
+++ b/packages/cli/src/preview-server/render-queue/job.ts
@@ -43,6 +43,7 @@ export type RenderJob = {
id: string;
outputLocation: string;
deletedOutputLocation: boolean;
+ verbose: boolean;
} & RenderJobDynamicStatus &
RenderJobDynamicFields;
@@ -57,6 +58,7 @@ type AddRenderRequestDynamicFields =
quality: number | null;
frame: number;
scale: number;
+ verbose: boolean;
}
| {
type: 'composition';
diff --git a/packages/cli/src/preview-server/render-queue/process-still.ts b/packages/cli/src/preview-server/render-queue/process-still.ts
index 5f69da7bc1..c389fce19e 100644
--- a/packages/cli/src/preview-server/render-queue/process-still.ts
+++ b/packages/cli/src/preview-server/render-queue/process-still.ts
@@ -31,8 +31,6 @@ export const processStill = async ({
port,
browser,
puppeteerTimeout,
- logLevel,
- configFileImageFormat,
} = await getCliOptions({
isLambda: false,
type: 'still',
@@ -66,8 +64,8 @@ export const processStill = async ({
width: null,
compositionIdFromUi: job.compositionId,
imageFormatFromUi: job.imageFormat,
- configFileImageFormat,
- logLevel,
+ configFileImageFormat: undefined,
+ logLevel: job.verbose ? 'verbose' : 'info',
onProgress,
indentOutput: true,
});
diff --git a/packages/cli/src/preview-server/routes/add-render.ts b/packages/cli/src/preview-server/routes/add-render.ts
index c5f1887482..331576b13c 100644
--- a/packages/cli/src/preview-server/routes/add-render.ts
+++ b/packages/cli/src/preview-server/routes/add-render.ts
@@ -27,6 +27,7 @@ export const handleAddRender: ApiHandler<AddRenderRequest, undefined> = ({
scale: input.scale,
cleanup: [],
deletedOutputLocation: false,
+ verbose: input.verbose,
},
entryPoint,
remotionRoot,
diff --git a/packages/cli/src/render-flows/still.ts b/packages/cli/src/render-flows/still.ts
index c086a93e4c..e54953a7c9 100644
--- a/packages/cli/src/render-flows/still.ts
+++ b/packages/cli/src/render-flows/still.ts
@@ -120,7 +120,11 @@ export const renderStillFlow = async ({
onProgress({progress, message});
};
- Log.verboseIndent(indentOutput, 'Browser executable: ', browserExecutable);
+ Log.verboseAdvanced(
+ {indent: indentOutput, logLevel},
+ 'Browser executable: ',
+ browserExecutable
+ );
const shouldDumpIo = RenderInternals.isEqualOrBelowLogLevel(
logLevel,
'verbose'
@@ -150,6 +154,7 @@ export const renderStillFlow = async ({
updateProgress();
},
indentOutput: true,
+ logLevel,
}
);
@@ -203,8 +208,8 @@ export const renderStillFlow = async ({
recursive: true,
});
- Log.infoIndent(
- indentOutput,
+ Log.infoAdvanced(
+ {indent: indentOutput, logLevel},
chalk.gray(
`Entry point = ${fullEntryPoint} (${entryPointReason}), Output = ${relativeOutputLocation}, Format = ${imageFormat} (${source}), Composition = ${compositionId} (${reason})`
)
@@ -274,14 +279,21 @@ export const renderStillFlow = async ({
totalFrames: 1,
};
updateProgress();
- Log.infoIndent(indentOutput);
+ Log.infoAdvanced({indent: indentOutput, logLevel});
const closeBrowserPromise = puppeteerInstance.close(false);
- Log.infoIndent(indentOutput, chalk.cyan(`▶️ ${absoluteOutputLocation}`));
+ Log.infoAdvanced(
+ {indent: indentOutput, logLevel},
+ chalk.cyan(`▶️ ${absoluteOutputLocation}`)
+ );
await closeBrowserPromise;
await RenderInternals.cleanDownloadMap(downloadMap);
await cleanupBundle();
- Log.verboseIndent(indentOutput, 'Cleaned up', downloadMap.assetDir);
+ Log.verboseAdvanced(
+ {indent: indentOutput, logLevel},
+ 'Cleaned up',
+ downloadMap.assetDir
+ );
};
diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsx
index 780c67d6a4..cb467d09a0 100644
--- a/packages/cli/src/render.tsx
+++ b/packages/cli/src/render.tsx
@@ -127,6 +127,7 @@ export const render = async (remotionRoot: string, args: string[]) => {
publicDir,
onProgress: () => undefined,
indentOutput: false,
+ logLevel: ConfigInternals.Logging.getLogLevel(),
}
);
diff --git a/packages/cli/src/setup-cache.ts b/packages/cli/src/setup-cache.ts
index e11803c136..0b2366a63b 100644
--- a/packages/cli/src/setup-cache.ts
+++ b/packages/cli/src/setup-cache.ts
@@ -1,5 +1,6 @@
import type {LegacyBundleOptions} from '@remotion/bundler';
import {bundle, BundlerInternals} from '@remotion/bundler';
+import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import {ConfigInternals} from './config';
import {Log} from './log';
@@ -22,6 +23,7 @@ export const bundleOnCliOrTakeServeUrl = async ({
publicDir,
onProgress,
indentOutput,
+ logLevel,
}: {
fullPath: string;
remotionRoot: string;
@@ -29,6 +31,7 @@ export const bundleOnCliOrTakeServeUrl = async ({
publicDir: string | null;
onProgress: (params: {progress: number; message: string}) => void;
indentOutput: boolean;
+ logLevel: LogLevel;
}): Promise<{
urlOrBundle: string;
cleanup: () => Promise<void>;
@@ -46,7 +49,8 @@ export const bundleOnCliOrTakeServeUrl = async ({
steps,
publicDir,
onProgressCallback: onProgress,
- indentOutput,
+ indent: indentOutput,
+ logLevel,
});
return {
@@ -61,14 +65,16 @@ export const bundleOnCli = async ({
remotionRoot,
publicDir,
onProgressCallback,
- indentOutput,
+ indent,
+ logLevel,
}: {
fullPath: string;
steps: RenderStep[];
remotionRoot: string;
publicDir: string | null;
onProgressCallback: (params: {progress: number; message: string}) => void;
- indentOutput: boolean;
+ indent: boolean;
+ logLevel: LogLevel;
}) => {
const shouldCache = ConfigInternals.getWebpackCaching();
@@ -147,13 +153,16 @@ export const bundleOnCli = async ({
hash
);
if (cacheExistedBefore !== 'does-not-exist' && !shouldCache) {
- Log.infoIndent(indentOutput, '🧹 Cache disabled but found. Deleting... ');
+ Log.infoAdvanced(
+ {indent, logLevel},
+ '🧹 Cache disabled but found. Deleting... '
+ );
await BundlerInternals.clearCache(remotionRoot);
}
if (cacheExistedBefore === 'other-exists' && shouldCache) {
- Log.infoIndent(
- indentOutput,
+ Log.infoAdvanced(
+ {indent, logLevel},
'🧹 Webpack config change detected. Clearing cache... '
);
await BundlerInternals.clearCache(remotionRoot);
@@ -162,7 +171,7 @@ export const bundleOnCli = async ({
const bundleStartTime = Date.now();
const bundlingProgress = createOverwriteableCliOutput({
quiet: quietFlagProvided(),
- indent: indentOutput,
+ indent,
});
let bundlingState: BundlingState = {
@@ -195,7 +204,7 @@ export const bundleOnCli = async ({
};
updateProgress(true);
- Log.verboseIndent(indentOutput, 'Bundled under', bundled);
+ Log.verboseAdvanced({indent, logLevel}, 'Bundled under', bundled);
const cacheExistedAfter =
BundlerInternals.cacheExists(remotionRoot, 'production', hash) === 'exists';
@@ -204,8 +213,8 @@ export const bundleOnCli = async ({
cacheExistedBefore === 'does-not-exist' ||
cacheExistedBefore === 'other-exists'
) {
- Log.infoIndent(
- indentOutput,
+ Log.infoAdvanced(
+ {indent, logLevel},
'⚡️ Cached bundle. Subsequent renders will be faster.'
);
}