Skip to content

🎥 Make videos programmatically with React

kill verbose: boolean

Jonny Burgerbf58b1d9ed7d
diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.ts
index c037c00217..0b96f7b1a7 100644
--- a/packages/cli/src/benchmark.ts
+++ b/packages/cli/src/benchmark.ts
@@ -143,9 +143,15 @@ export const benchmarkCommand = async (
if (!file) {
Log.error('No entry file passed.');
- Log.info('Pass an additional argument specifying the entry file');
- Log.info();
- Log.info(`$ remotion benchmark <entry file>`);
+ Log.infoAdvanced(
+ {indent: false, logLevel},
+ 'Pass an additional argument specifying the entry file',
+ );
+ Log.infoAdvanced({indent: false, logLevel});
+ Log.infoAdvanced(
+ {indent: false, logLevel},
+ `$ remotion benchmark <entry file>`,
+ );
process.exit(1);
}
@@ -297,8 +303,9 @@ export const benchmarkCommand = async (
updatesDontOverwrite: shouldUseNonOverlayingLogger({logLevel}),
indent: false,
});
- Log.info();
- Log.info(
+ Log.infoAdvanced({indent: false, logLevel});
+ Log.infoAdvanced(
+ {indent: false, logLevel},
`${chalk.bold(`Benchmark #${count++}:`)} ${chalk.gray(
`composition=${composition.id} concurrency=${con} codec=${codec} (${codecReason})`,
)}`,
@@ -382,5 +389,5 @@ export const benchmarkCommand = async (
}
}
- Log.info();
+ Log.infoAdvanced({indent: false, logLevel});
};
diff --git a/packages/cli/src/cleanup-before-quit.ts b/packages/cli/src/cleanup-before-quit.ts
index 2deb5eec3d..e2599a7f44 100644
--- a/packages/cli/src/cleanup-before-quit.ts
+++ b/packages/cli/src/cleanup-before-quit.ts
@@ -34,7 +34,7 @@ export const handleCtrlC = ({
logLevel: LogLevel;
}) => {
process.on('SIGINT', () => {
- Log.info();
+ Log.infoAdvanced({indent: false, logLevel});
cleanupBeforeQuit({indent, logLevel});
process.exit(0);
});
diff --git a/packages/cli/src/cloudrun-command.ts b/packages/cli/src/cloudrun-command.ts
index 3d3fcf6ade..e027ddf42f 100644
--- a/packages/cli/src/cloudrun-command.ts
+++ b/packages/cli/src/cloudrun-command.ts
@@ -1,8 +1,13 @@
+import type {LogLevel} from '@remotion/renderer';
import {Log} from './log';
import {getPackageManager} from './preview-server/get-package-manager';
import {getRemotionVersion} from './preview-server/update-available';
-export const cloudrunCommand = async (remotionRoot: string, args: string[]) => {
+export const cloudrunCommand = async (
+ remotionRoot: string,
+ args: string[],
+ logLevel: LogLevel,
+) => {
try {
const path = require.resolve('@remotion/cloudrun', {
paths: [remotionRoot],
@@ -17,9 +22,12 @@ export const cloudrunCommand = async (remotionRoot: string, args: string[]) => {
manager === 'unknown' ? 'npm i' : manager.installCommand;
Log.error(err);
Log.error('Remotion Cloud Run is not installed.');
- Log.info('');
- Log.info('You can install it using:');
- Log.info(`${installCommand} @remotion/cloudrun@${getRemotionVersion()}`);
+ Log.infoAdvanced({indent: false, logLevel}, '');
+ Log.infoAdvanced({indent: false, logLevel}, 'You can install it using:');
+ Log.infoAdvanced(
+ {indent: false, logLevel},
+ `${installCommand} @remotion/cloudrun@${getRemotionVersion()}`,
+ );
process.exit(1);
}
};
diff --git a/packages/cli/src/index.tsx b/packages/cli/src/index.tsx
index 166c514e7d..d4a30c1c76 100644
--- a/packages/cli/src/index.tsx
+++ b/packages/cli/src/index.tsx
@@ -85,7 +85,7 @@ export const cli = async () => {
} else if (command === 'lambda') {
await lambdaCommand(remotionRoot, args);
} else if (command === 'cloudrun') {
- await cloudrunCommand(remotionRoot, args);
+ await cloudrunCommand(remotionRoot, args, logLevel);
} else if (command === 'render') {
await render(remotionRoot, args, logLevel);
} else if (command === 'still') {
diff --git a/packages/lambda/src/cli/commands/compositions/index.ts b/packages/lambda/src/cli/commands/compositions/index.ts
index 17dc58ef1a..55a46645af 100644
--- a/packages/lambda/src/cli/commands/compositions/index.ts
+++ b/packages/lambda/src/cli/commands/compositions/index.ts
@@ -38,7 +38,7 @@ export const compositionsCommand = async (
const region = getAwsRegion();
validateServeUrl(serveUrl);
- const functionName = await findFunctionName();
+ const functionName = await findFunctionName(logLevel);
const comps = await getCompositionsOnLambda({
functionName,
diff --git a/packages/lambda/src/cli/commands/render/progress.ts b/packages/lambda/src/cli/commands/render/progress.ts
index b4624684c0..16fb9bb02c 100644
--- a/packages/lambda/src/cli/commands/render/progress.ts
+++ b/packages/lambda/src/cli/commands/render/progress.ts
@@ -1,4 +1,5 @@
import {CliInternals} from '@remotion/cli';
+import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import {Internals} from 'remotion';
import type {
@@ -213,7 +214,7 @@ export const makeProgressString = ({
steps,
downloadInfo,
retriesInfo,
- verbose,
+ logLevel,
timeToEncode,
totalFrames,
}: {
@@ -221,7 +222,7 @@ export const makeProgressString = ({
steps: number;
downloadInfo: DownloadedInfo | null;
retriesInfo: ChunkRetry[];
- verbose: boolean;
+ logLevel: LogLevel;
timeToEncode: number | null;
totalFrames: number | null;
}) => {
@@ -238,7 +239,7 @@ export const makeProgressString = ({
timeToEncode,
totalFrames,
}),
- makeCleanupProgress(progress.cleanupInfo, steps, verbose),
+ makeCleanupProgress(progress.cleanupInfo, steps, logLevel === 'verbose'),
downloadInfo ? makeDownloadProgress(downloadInfo, steps) : null,
]
.filter(Internals.truthy)
diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.ts
index 631f2fef77..5795103712 100644
--- a/packages/lambda/src/cli/commands/render/render.ts
+++ b/packages/lambda/src/cli/commands/render/render.ts
@@ -156,7 +156,7 @@ export const renderCommand = async (
uiImageFormat: null,
});
- const functionName = await findFunctionName();
+ const functionName = await findFunctionName(logLevel);
const maxRetries = parsedLambdaCli['max-retries'] ?? DEFAULT_MAX_RETRIES;
validateMaxRetries(maxRetries);
@@ -236,10 +236,6 @@ export const renderCommand = async (
`renderId = ${res.renderId}, codec = ${codec} (${reason})`,
),
);
- const verbose = RenderInternals.isEqualOrBelowLogLevel(
- ConfigInternals.Logging.getLogLevel(),
- 'verbose',
- );
Log.verboseAdvanced(
{indent: false, logLevel},
@@ -262,7 +258,7 @@ export const renderCommand = async (
steps: totalSteps,
downloadInfo: null,
retriesInfo: status.retriesInfo,
- verbose,
+ logLevel,
totalFrames: getTotalFrames(status),
timeToEncode: status.timeToEncode,
}),
@@ -285,7 +281,7 @@ export const renderCommand = async (
steps: totalSteps,
retriesInfo: newStatus.retriesInfo,
downloadInfo: null,
- verbose,
+ logLevel,
timeToEncode: newStatus.timeToEncode,
totalFrames: getTotalFrames(newStatus),
}),
@@ -299,7 +295,7 @@ export const renderCommand = async (
steps: totalSteps,
downloadInfo: null,
retriesInfo: newStatus.retriesInfo,
- verbose,
+ logLevel,
timeToEncode: newStatus.timeToEncode,
totalFrames: getTotalFrames(newStatus),
}),
@@ -324,7 +320,7 @@ export const renderCommand = async (
downloaded,
totalSize,
},
- verbose,
+ logLevel,
timeToEncode: newStatus.timeToEncode,
totalFrames: getTotalFrames(newStatus),
}),
@@ -342,7 +338,7 @@ export const renderCommand = async (
downloaded: sizeInBytes,
totalSize: sizeInBytes,
},
- verbose,
+ logLevel,
timeToEncode: newStatus.timeToEncode,
totalFrames: getTotalFrames(newStatus),
}),
diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.ts
index 205565a1cb..81ff4dd2de 100644
--- a/packages/lambda/src/cli/commands/still.ts
+++ b/packages/lambda/src/cli/commands/still.ts
@@ -113,7 +113,7 @@ export const stillCommand = async (
const downloadName = args[2] ?? null;
const outName = parsedLambdaCli['out-name'];
- const functionName = await findFunctionName();
+ const functionName = await findFunctionName(logLevel);
const maxRetries = parsedLambdaCli['max-retries'] ?? DEFAULT_MAX_RETRIES;
validateMaxRetries(maxRetries);
diff --git a/packages/lambda/src/cli/helpers/find-function-name.ts b/packages/lambda/src/cli/helpers/find-function-name.ts
index ee9aa80b03..3f8cbbad5b 100644
--- a/packages/lambda/src/cli/helpers/find-function-name.ts
+++ b/packages/lambda/src/cli/helpers/find-function-name.ts
@@ -1,3 +1,4 @@
+import type {LogLevel, LogOptions} from '@remotion/renderer';
import {VERSION} from 'remotion/version';
import {getFunctions} from '../../api/get-functions';
import {BINARY_NAME} from '../../shared/constants';
@@ -10,7 +11,7 @@ import {getAwsRegion} from '../get-aws-region';
import {Log} from '../log';
import {quit} from './quit';
-export const findFunctionName = async () => {
+export const findFunctionName = async (logLevel: LogLevel) => {
const remotionLambdas = await getFunctions({
region: getAwsRegion(),
compatibleOnly: false,
@@ -18,6 +19,10 @@ export const findFunctionName = async () => {
let lambdasWithMatchingVersion = remotionLambdas.filter(
(l) => l.version === VERSION,
);
+ const logOptions: LogOptions = {
+ indent: false,
+ logLevel,
+ };
if (lambdasWithMatchingVersion.length === 0) {
Log.error(
@@ -29,11 +34,12 @@ export const findFunctionName = async () => {
);
}
- Log.info('Run');
- Log.info(
+ Log.infoAdvanced(logOptions, 'Run');
+ Log.infoAdvanced(
+ logOptions,
` npx ${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_DEPLOY_SUBCOMMAND}`,
);
- Log.info(`to deploy a new lambda function.`);
+ Log.infoAdvanced(logOptions, `to deploy a new lambda function.`);
quit(1);
}
@@ -47,24 +53,29 @@ export const findFunctionName = async () => {
Log.error(
`No lambda function with name "${parsedLambdaCli['function-name']}" and version ${VERSION} found in your account.`,
);
- Log.info();
+ Log.infoAdvanced(logOptions);
if (prevFunctions.length === 0) {
- Log.info(
+ Log.infoAdvanced(
+ logOptions,
`No functions for version ${VERSION} were found, deploy one using:`,
);
- Log.info(
+ Log.infoAdvanced(
+ logOptions,
` npx ${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_DEPLOY_SUBCOMMAND}`,
);
quit(1);
}
- Log.info('The following functions were found:');
+ Log.infoAdvanced(logOptions, 'The following functions were found:');
for (const l of prevFunctions) {
- Log.info(`- ${l.functionName} (v${l.version})`);
+ Log.infoAdvanced(logOptions, `- ${l.functionName} (v${l.version})`);
}
- Log.info('Remove the `--function-name` parameter use one of them.');
+ Log.infoAdvanced(
+ logOptions,
+ 'Remove the `--function-name` parameter use one of them.',
+ );
quit(1);
}
@@ -72,23 +83,27 @@ export const findFunctionName = async () => {
Log.error(
'More than 1 lambda function found in your account. Unsure which one to use.',
);
- Log.info();
- Log.info('Possible solutions:');
- Log.info(
+ Log.infoAdvanced(logOptions);
+ Log.infoAdvanced(logOptions, 'Possible solutions:');
+ Log.infoAdvanced(
+ logOptions,
'- Define using `--function-name` which function you want to use.',
);
- Log.info(
+ Log.infoAdvanced(
+ logOptions,
`- Delete extraneous lambda functions in your AWS console or using:`,
);
- Log.info(
+ Log.infoAdvanced(
+ logOptions,
` npx ${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_RM_SUBCOMMAND} $(npx ${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_LS_SUBCOMMAND} -q) -y`,
);
- Log.info();
- Log.info(
+ Log.infoAdvanced(logOptions);
+ Log.infoAdvanced(
+ logOptions,
`The following functions were found (only showing v${VERSION}):`,
);
for (const l of lambdasWithMatchingVersion) {
- Log.info(`- ${l.functionName}`);
+ Log.infoAdvanced(logOptions, `- ${l.functionName}`);
}
quit(1);
diff --git a/packages/lambda/src/functions/helpers/merge-chunks.ts b/packages/lambda/src/functions/helpers/merge-chunks.ts
index 7911c434f5..02ce35088a 100644
--- a/packages/lambda/src/functions/helpers/merge-chunks.ts
+++ b/packages/lambda/src/functions/helpers/merge-chunks.ts
@@ -56,7 +56,6 @@ export const mergeChunksAndFinishRender = async (options: {
key: string;
privacy: Privacy;
inputProps: SerializedInputProps;
- verbose: boolean;
serializedResolvedProps: SerializedInputProps;
renderMetadata: RenderMetadata;
onAllChunks: OnAllChunksAvailable;
@@ -210,14 +209,15 @@ export const mergeChunksAndFinishRender = async (options: {
renderId: options.renderId,
});
- const deletProm = options.verbose
- ? Promise.resolve(0)
- : cleanupFiles({
- region: getCurrentRegionInFunction(),
- bucket: options.bucketName,
- contents,
- jobs,
- });
+ const deletProm =
+ options.logLevel === 'verbose'
+ ? Promise.resolve(0)
+ : cleanupFiles({
+ region: getCurrentRegionInFunction(),
+ bucket: options.bucketName,
+ contents,
+ jobs,
+ });
const cleanupSerializedInputPropsProm = cleanupSerializedInputProps({
bucketName: options.bucketName,
diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.ts
index 2eb9db6487..941458c152 100644
--- a/packages/lambda/src/functions/launch.ts
+++ b/packages/lambda/src/functions/launch.ts
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
import {InvokeCommand} from '@aws-sdk/client-lambda';
+import type {LogOptions} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import {VERSION} from 'remotion/version';
import {getLambdaClient} from '../shared/aws-clients';
@@ -97,13 +98,11 @@ const innerLaunchHandler = async ({
params,
options,
onAllChunksAvailable,
- verbose,
}: {
functionName: string;
params: LambdaPayload;
options: Options;
onAllChunksAvailable: OnAllChunksAvailable;
- verbose: boolean;
}): Promise<PostRenderData> => {
if (params.type !== LambdaRoutines.launch) {
throw new Error('Expected launch type');
@@ -125,8 +124,13 @@ const innerLaunchHandler = async ({
propsType: 'input-props',
});
+ const logOptions: LogOptions = {
+ indent: false,
+ logLevel: params.logLevel,
+ };
const serializedInputPropsWithCustomSchema = await inputPropsPromise;
- RenderInternals.Log.info(
+ RenderInternals.Log.infoAdvanced(
+ logOptions,
'Validating composition, input props:',
serializedInputPropsWithCustomSchema,
);
@@ -145,7 +149,11 @@ const innerLaunchHandler = async ({
server: undefined,
offthreadVideoCacheSizeInBytes: params.offthreadVideoCacheSizeInBytes,
});
- RenderInternals.Log.info('Composition validated, resolved props', comp.props);
+ RenderInternals.Log.infoAdvanced(
+ logOptions,
+ 'Composition validated, resolved props',
+ comp.props,
+ );
validateDurationInFrames(comp.durationInFrames, {
component: 'passed to a Lambda render',
@@ -264,7 +272,8 @@ const innerLaunchHandler = async ({
return payload;
});
- RenderInternals.Log.info(
+ RenderInternals.Log.infoAdvanced(
+ logOptions,
'Render plan: ',
chunks.map((c, i) => `Chunk ${i} (Frames ${c[0]} - ${c[1]})`).join(', '),
);
@@ -375,7 +384,6 @@ const innerLaunchHandler = async ({
renderBucketName,
inputProps: params.inputProps,
serializedResolvedProps,
- verbose,
renderMetadata,
onAllChunks: onAllChunksAvailable,
audioBitrate: params.audioBitrate,
@@ -406,17 +414,21 @@ export const launchHandler = async (
params.rendererFunctionName ??
(process.env.AWS_LAMBDA_FUNCTION_NAME as string);
- const verbose = RenderInternals.isEqualOrBelowLogLevel(
- params.logLevel,
- 'verbose',
- );
+ const logOptions: LogOptions = {
+ indent: false,
+ logLevel: params.logLevel,
+ };
const onTimeout = async () => {
if (allChunksAvailable) {
- RenderInternals.Log.info(
+ RenderInternals.Log.infoAdvanced(
+ logOptions,
'All chunks are available, but the function is about to time out.',
);
- RenderInternals.Log.info('Spawning another function to merge chunks.');
+ RenderInternals.Log.infoAdvanced(
+ logOptions,
+ 'Spawning another function to merge chunks.',
+ );
try {
await callFunctionWithRetry({
@@ -425,7 +437,6 @@ export const launchHandler = async (
type: LambdaRoutines.merge,
renderId: params.renderId,
bucketName: params.bucketName,
- verbose,
outName: params.outName,
serializedResolvedProps: allChunksAvailable.serializedResolvedProps,
inputProps: allChunksAvailable.inputProps,
@@ -433,10 +444,12 @@ export const launchHandler = async (
},
retries: 2,
});
- RenderInternals.Log.info(
+ RenderInternals.Log.infoAdvanced(
+ logOptions,
`New function successfully invoked. See the CloudWatch logs for it:`,
);
- RenderInternals.Log.info(
+ RenderInternals.Log.infoAdvanced(
+ logOptions,
getCloudwatchMethodUrl({
functionName: process.env.AWS_LAMBDA_FUNCTION_NAME as string,
method: LambdaRoutines.merge,
@@ -445,7 +458,10 @@ export const launchHandler = async (
renderId: params.renderId,
}),
);
- RenderInternals.Log.info('This function will now time out.');
+ RenderInternals.Log.infoAdvanced(
+ logOptions,
+ 'This function will now time out.',
+ );
} catch (err) {
if (process.env.NODE_ENV === 'test') {
throw err;
@@ -533,7 +549,8 @@ export const launchHandler = async (
Math.max(options.getRemainingTimeInMillis() - 1000, 1000),
);
- RenderInternals.Log.info(
+ RenderInternals.Log.infoAdvanced(
+ logOptions,
`Function has ${Math.max(
options.getRemainingTimeInMillis() - 1000,
1000,
@@ -548,7 +565,6 @@ export const launchHandler = async (
onAllChunksAvailable: ({inputProps, serializedResolvedProps}) => {
allChunksAvailable = {inputProps, serializedResolvedProps};
},
- verbose,
});
clearTimeout(webhookDueToTimeout);
diff --git a/packages/lambda/src/functions/merge.ts b/packages/lambda/src/functions/merge.ts
index 3bf06870a6..1daf0093f1 100644
--- a/packages/lambda/src/functions/merge.ts
+++ b/packages/lambda/src/functions/merge.ts
@@ -67,7 +67,6 @@ export const mergeHandler = async (
renderId: params.renderId,
renderMetadata,
serializedResolvedProps: params.serializedResolvedProps,
- verbose: params.verbose,
onAllChunks: () => {
RenderInternals.Log.info('All chunks have been downloaded now.');
},
diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.ts
index 072a7368d3..6a917131ee 100644
--- a/packages/lambda/src/shared/constants.ts
+++ b/packages/lambda/src/shared/constants.ts
@@ -417,7 +417,6 @@ export type LambdaPayloads = {
outName: OutNameInput | null;
inputProps: SerializedInputProps;
serializedResolvedProps: SerializedInputProps;
- verbose: boolean;
logLevel: LogLevel;
};
};
diff --git a/packages/renderer/src/browser/BrowserPage.ts b/packages/renderer/src/browser/BrowserPage.ts
index fe18041d37..458e9d415e 100644
--- a/packages/renderer/src/browser/BrowserPage.ts
+++ b/packages/renderer/src/browser/BrowserPage.ts
@@ -149,7 +149,7 @@ export class Page extends EventEmitter {
super();
this.#client = client;
this.#target = target;
- this.#frameManager = new FrameManager(client, this);
+ this.#frameManager = new FrameManager(client, this, indent, logLevel);
this.screenshotTaskQueue = new TaskQueue();
this.browser = browser;
this.id = String(Math.random());
diff --git a/packages/renderer/src/browser/FrameManager.ts b/packages/renderer/src/browser/FrameManager.ts
index de5ef1b472..b8f515b86e 100644
--- a/packages/renderer/src/browser/FrameManager.ts
+++ b/packages/renderer/src/browser/FrameManager.ts
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+import type {LogLevel} from '../log-level';
import {assert} from './assert';
import type {Page} from './BrowserPage';
import type {CDPSession} from './Connection';
@@ -73,11 +74,16 @@ export class FrameManager extends EventEmitter {
return this.#client;
}
- constructor(client: CDPSession, page: Page) {
+ constructor(
+ client: CDPSession,
+ page: Page,
+ indent: boolean,
+ logLevel: LogLevel,
+ ) {
super();
this.#client = client;
this.#page = page;
- this.#networkManager = new NetworkManager(client, this);
+ this.#networkManager = new NetworkManager(client, this, indent, logLevel);
this.setupEventListeners(this.#client);
}
diff --git a/packages/renderer/src/browser/NetworkManager.ts b/packages/renderer/src/browser/NetworkManager.ts
index ec48153669..efc8de1cb3 100644
--- a/packages/renderer/src/browser/NetworkManager.ts
+++ b/packages/renderer/src/browser/NetworkManager.ts
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+import type {LogLevel} from '../log-level';
import {Log} from '../logger';
import type {Commands} from './devtools-commands';
import type {
@@ -52,10 +53,19 @@ export class NetworkManager extends EventEmitter {
#client: CDPSession;
#frameManager: FrameManager;
#networkEventManager = new NetworkEventManager();
- constructor(client: CDPSession, frameManager: FrameManager) {
+ #indent: boolean;
+ #logLevel: LogLevel;
+ constructor(
+ client: CDPSession,
+ frameManager: FrameManager,
+ indent: boolean,
+ logLevel: LogLevel,
+ ) {
super();
this.#client = client;
this.#frameManager = frameManager;
+ this.#indent = indent;
+ this.#logLevel = logLevel;
this.#client.on('Fetch.requestPaused', this.#onRequestPaused.bind(this));
this.#client.on(
@@ -336,7 +346,10 @@ export class NetworkManager extends EventEmitter {
}
if (!event.canceled) {
- Log.warn(`Browser failed to load ${request._url}: ${event.errorText}`);
+ Log.warnAdvanced(
+ {indent: this.#indent, logLevel: this.#logLevel},
+ `Browser failed to load ${request._url}: ${event.errorText}`,
+ );
}
this.#forgetRequest(request, true);