Skip to content

πŸŽ₯ Make videos programmatically with React

error

Jonny Burgeraae5bf279cac
diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.ts
index 0034fd1ccc..50c4b3ce4e 100644
--- a/packages/cli/src/benchmark.ts
+++ b/packages/cli/src/benchmark.ts
@@ -166,7 +166,7 @@ export const benchmarkCommand = async (
);
if (!file) {
- Log.error('No entry file passed.');
+ Log.errorAdvanced({indent: false, logLevel}, 'No entry file passed.');
Log.infoAdvanced(
{indent: false, logLevel},
'Pass an additional argument specifying the entry file',
@@ -299,7 +299,7 @@ export const benchmarkCommand = async (
.split(',')
.map((c) => c.trim())
.filter(truthy)
- : await showMultiCompositionsPicker(comps)
+ : await showMultiCompositionsPicker(comps, logLevel)
) as string[];
const compositions = ids.map((compId) => {
@@ -313,7 +313,8 @@ export const benchmarkCommand = async (
});
if (compositions.length === 0) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'No composition IDs passed. Add another argument to the command specifying at least 1 composition ID.',
);
}
diff --git a/packages/cli/src/bundle.ts b/packages/cli/src/bundle.ts
index 32e4d471b8..9126da77a9 100644
--- a/packages/cli/src/bundle.ts
+++ b/packages/cli/src/bundle.ts
@@ -26,7 +26,8 @@ export const bundleCommand = async (
reason !== 'argument passed - found in cwd' &&
reason !== 'argument passed - found in root'
) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`Entry point was specified as ${chalk.bold(
explicitlyPassed,
)}, but it was not found.`,
@@ -37,11 +38,15 @@ export const bundleCommand = async (
const updatesDontOverwrite = shouldUseNonOverlayingLogger({logLevel});
if (!file) {
- Log.error('No entry point found.');
- Log.error(
+ Log.errorAdvanced({indent: false, logLevel}, 'No entry point found.');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'Pass another argument to the command specifying the entry point.',
);
- Log.error('See: https://www.remotion.dev/docs/terminology/entry-point');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'See: https://www.remotion.dev/docs/terminology/entry-point',
+ );
process.exit(1);
}
@@ -65,13 +70,18 @@ export const bundleCommand = async (
const existsIndexHtml = existsSync(path.join(outputPath, 'index.html'));
const isEmpty = readdirSync(outputPath).length === 0;
if (!existsIndexHtml && !isEmpty) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`The folder at ${outputPath} already exists, and needs to be deleted before a new bundle can be created.`,
);
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'However, it does not look like the folder was created by `npx remotion bundle` (no index.html).',
);
- Log.error('Aborting to prevent accidental data loss.');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Aborting to prevent accidental data loss.',
+ );
process.exit(1);
}
diff --git a/packages/cli/src/cloudrun-command.ts b/packages/cli/src/cloudrun-command.ts
index fa2062ad9f..47a22ba45f 100644
--- a/packages/cli/src/cloudrun-command.ts
+++ b/packages/cli/src/cloudrun-command.ts
@@ -22,8 +22,11 @@ export const cloudrunCommand = async (
);
const installCommand =
manager === 'unknown' ? 'npm i' : manager.installCommand;
- Log.error(err);
- Log.error('Remotion Cloud Run is not installed.');
+ Log.errorAdvanced({indent: false, logLevel}, err);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Remotion Cloud Run is not installed.',
+ );
Log.infoAdvanced({indent: false, logLevel}, '');
Log.infoAdvanced({indent: false, logLevel}, 'You can install it using:');
Log.infoAdvanced(
diff --git a/packages/cli/src/code-frame.ts b/packages/cli/src/code-frame.ts
index 243e90cf16..61926c72c5 100644
--- a/packages/cli/src/code-frame.ts
+++ b/packages/cli/src/code-frame.ts
@@ -1,5 +1,6 @@
import type {
ErrorWithStackFrame,
+ LogLevel,
SymbolicatedStackFrame,
} from '@remotion/renderer';
import {chalk} from './chalk';
@@ -64,17 +65,24 @@ const logLine = (frame: SymbolicatedStackFrame) => {
);
};
-export const printCodeFrameAndStack = (err: ErrorWithStackFrame) => {
+export const printCodeFrameAndStack = (
+ err: ErrorWithStackFrame,
+ logLevel: LogLevel,
+) => {
if (
!err.symbolicatedStackFrames ||
err.symbolicatedStackFrames.length === 0
) {
- Log.error(err.stack);
+ Log.errorAdvanced({indent: false, logLevel}, err.stack);
return;
}
const firstFrame = err.symbolicatedStackFrames[0];
- Log.error(chalk.bgRed(chalk.white(` ${err.name} `)), err.message);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ chalk.bgRed(chalk.white(` ${err.name} `)),
+ err.message,
+ );
printCodeFrame(firstFrame);
Log.info();
for (const frame of err.symbolicatedStackFrames) {
@@ -93,8 +101,11 @@ export const printCodeFrameAndStack = (err: ErrorWithStackFrame) => {
}
if (err.delayRenderCall) {
- Log.error();
- Log.error('πŸ•§ The delayRender() call is located at:');
+ Log.errorAdvanced({indent: false, logLevel});
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'πŸ•§ The delayRender() call is located at:',
+ );
for (const frame of err.delayRenderCall) {
const showCodeFrame =
(!frame.originalFileName?.includes('node_modules') &&
diff --git a/packages/cli/src/composition-prompts.ts b/packages/cli/src/composition-prompts.ts
index fe4223d240..83c34a0366 100644
--- a/packages/cli/src/composition-prompts.ts
+++ b/packages/cli/src/composition-prompts.ts
@@ -1,3 +1,4 @@
+import type {LogLevel} from '@remotion/renderer';
import type {PromptObject} from 'prompts';
import prompts from 'prompts';
import {Log} from './log';
@@ -7,10 +8,10 @@ type Question<V extends string = string> = PromptObject<V> & {
};
type NamelessQuestion = Omit<Question<'value'>, 'name'>;
-function prompt(questions: Question) {
+function prompt(questions: Question, logLevel: LogLevel) {
return prompts([questions], {
onCancel() {
- Log.error('No composition selected.');
+ Log.errorAdvanced({indent: false, logLevel}, 'No composition selected.');
process.exit(1);
},
});
@@ -18,11 +19,15 @@ function prompt(questions: Question) {
export async function selectAsync(
question: NamelessQuestion,
+ logLevel: LogLevel,
): Promise<string | string[]> {
- const {value} = await prompt({
- ...question,
- name: 'value',
- type: question.type,
- });
+ const {value} = await prompt(
+ {
+ ...question,
+ name: 'value',
+ type: question.type,
+ },
+ logLevel,
+ );
return value ?? null;
}
diff --git a/packages/cli/src/compositions.ts b/packages/cli/src/compositions.ts
index 1fd3fa8cfb..4c29d5eb56 100644
--- a/packages/cli/src/compositions.ts
+++ b/packages/cli/src/compositions.ts
@@ -25,11 +25,16 @@ export const listCompositionsCommand = async (
const {file, reason} = findEntryPoint(args, remotionRoot, logLevel);
if (!file) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'The `compositions` command requires you to specify a entry point. For example',
);
- Log.error(' npx remotion compositions src/index.ts');
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ ' npx remotion compositions src/index.ts',
+ );
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'See https://www.remotion.dev/docs/register-root for more information.',
);
process.exit(1);
diff --git a/packages/cli/src/get-cli-options.ts b/packages/cli/src/get-cli-options.ts
index 62f00dd856..6a2eb5b1bc 100644
--- a/packages/cli/src/get-cli-options.ts
+++ b/packages/cli/src/get-cli-options.ts
@@ -30,13 +30,15 @@ const getAndValidateFrameRange = (logLevel: LogLevel, indent: boolean) => {
export const getAndValidateAbsoluteOutputFile = (
relativeOutputLocation: string,
overwrite: boolean,
+ logLevel: LogLevel,
) => {
const absoluteOutputFile = path.resolve(
process.cwd(),
relativeOutputLocation,
);
if (fs.existsSync(absoluteOutputFile) && !overwrite) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`File at ${absoluteOutputFile} already exists. Use --overwrite to overwrite.`,
);
process.exit(1);
diff --git a/packages/cli/src/get-composition-id.ts b/packages/cli/src/get-composition-id.ts
index 6c8a17640b..b5d225e621 100644
--- a/packages/cli/src/get-composition-id.ts
+++ b/packages/cli/src/get-composition-id.ts
@@ -138,7 +138,10 @@ export const getCompositionId = async ({
serializedInputPropsWithCustomSchema,
offthreadVideoCacheSizeInBytes,
});
- const {compositionId, reason} = await showSingleCompositionsPicker(comps);
+ const {compositionId, reason} = await showSingleCompositionsPicker(
+ comps,
+ logLevel,
+ );
if (compositionId && typeof compositionId === 'string') {
return {
compositionId,
@@ -149,7 +152,10 @@ export const getCompositionId = async ({
}
}
- Log.error('Composition ID not passed.');
- Log.error('Pass an extra argument <composition-id>.');
+ Log.errorAdvanced({indent: false, logLevel}, 'Composition ID not passed.');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Pass an extra argument <composition-id>.',
+ );
process.exit(1);
};
diff --git a/packages/cli/src/get-config-file-name.ts b/packages/cli/src/get-config-file-name.ts
index 07f5ecbddf..9f81b43ce2 100644
--- a/packages/cli/src/get-config-file-name.ts
+++ b/packages/cli/src/get-config-file-name.ts
@@ -11,7 +11,8 @@ export const loadConfig = (remotionRoot: string): Promise<string | null> => {
if (parsedCli.config) {
const fullPath = path.resolve(process.cwd(), parsedCli.config);
if (!existsSync(fullPath)) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel: 'error'},
`You specified a config file location of "${parsedCli.config}" but no file under ${fullPath} was found.`,
);
process.exit(1);
diff --git a/packages/cli/src/get-env.ts b/packages/cli/src/get-env.ts
index 66781148b0..da94afba57 100644
--- a/packages/cli/src/get-env.ts
+++ b/packages/cli/src/get-env.ts
@@ -56,7 +56,8 @@ const watchEnvFile = ({
Log.info(chalk.blueBright(`Created env file ${envFile}`));
}
} catch (err) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`${envFile} update failed with error ${(err as Error).stack}`,
);
}
@@ -98,8 +99,11 @@ const getEnvForEnvFile = ({
...dotenv.parse(envFileData),
};
} catch (err) {
- Log.error(`Your .env file at ${envFile} could not not be parsed.`);
- Log.error(err);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ `Your .env file at ${envFile} could not not be parsed.`,
+ );
+ Log.errorAdvanced({indent: false, logLevel}, err);
process.exit(1);
}
};
@@ -129,9 +133,19 @@ export const getEnvironmentVariables = (
if (parsedCli['env-file']) {
const envFile = path.resolve(process.cwd(), parsedCli['env-file']);
if (!fs.existsSync(envFile)) {
- Log.error('You passed a --env-file but it could not be found.');
- Log.error('We looked for the file at:', envFile);
- Log.error('Check that your path is correct and try again.');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'You passed a --env-file but it could not be found.',
+ );
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'We looked for the file at:',
+ envFile,
+ );
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Check that your path is correct and try again.',
+ );
process.exit(1);
}
@@ -144,11 +158,19 @@ export const getEnvironmentVariables = (
if (configFileSetting) {
const envFile = path.resolve(remotionRoot, configFileSetting);
if (!fs.existsSync(envFile)) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'You specified a custom .env file using `Config.setDotEnvLocation()` in the config file but it could not be found',
);
- Log.error('We looked for the file at:', envFile);
- Log.error('Check that your path is correct and try again.');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'We looked for the file at:',
+ envFile,
+ );
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Check that your path is correct and try again.',
+ );
process.exit(1);
}
diff --git a/packages/cli/src/get-input-props.ts b/packages/cli/src/get-input-props.ts
index 2d4291af5f..9a0e763102 100644
--- a/packages/cli/src/get-input-props.ts
+++ b/packages/cli/src/get-input-props.ts
@@ -24,7 +24,8 @@ export const getInputProps = (
onUpdate(JSON.parse(fs.readFileSync(jsonFile, 'utf-8')));
Log.info(`Updated input props from ${jsonFile}.`);
} catch (err) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`${jsonFile} contains invalid JSON. Did not apply new input props.`,
);
}
@@ -36,12 +37,14 @@ export const getInputProps = (
return JSON.parse(parsedCli.props);
} catch (err) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'You passed --props but it was neither valid JSON nor a file path to a valid JSON file. Provided value: ' +
parsedCli.props,
);
Log.info('Got the following value:', parsedCli.props);
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'Check that your input is parseable using `JSON.parse` and try again.',
);
if (os.platform() === 'win32') {
diff --git a/packages/cli/src/index.tsx b/packages/cli/src/index.tsx
index 3a0bb90777..266ca7c9d8 100644
--- a/packages/cli/src/index.tsx
+++ b/packages/cli/src/index.tsx
@@ -111,7 +111,10 @@ export const cli = async () => {
process.exit(0);
} else {
if (command) {
- Log.error(`Command ${command} not found.`);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ `Command ${command} not found.`,
+ );
}
printHelp();
diff --git a/packages/cli/src/lambda-command.ts b/packages/cli/src/lambda-command.ts
index 58522a99d1..e1b78a7a9f 100644
--- a/packages/cli/src/lambda-command.ts
+++ b/packages/cli/src/lambda-command.ts
@@ -22,11 +22,15 @@ export const lambdaCommand = async (
);
const installCommand =
manager === 'unknown' ? 'npm i' : manager.installCommand;
- Log.error(err);
- Log.error('Remotion Lambda is not installed.');
- Log.info('');
- Log.info('You can install it using:');
- Log.info(
+ Log.errorAdvanced({indent: false, logLevel}, err);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Remotion Lambda is not installed.',
+ );
+ Log.infoAdvanced({indent: false, logLevel}, '');
+ Log.infoAdvanced({indent: false, logLevel}, 'You can install it using:');
+ Log.infoAdvanced(
+ {indent: false, logLevel},
`${installCommand} @remotion/lambda@${StudioServerInternals.getRemotionVersion()}`,
);
process.exit(1);
diff --git a/packages/cli/src/load-config.ts b/packages/cli/src/load-config.ts
index d6d9c8d89c..614b176b77 100644
--- a/packages/cli/src/load-config.ts
+++ b/packages/cli/src/load-config.ts
@@ -13,10 +13,15 @@ export const loadConfigFile = async (
const tsconfigJson = path.join(remotionRoot, 'tsconfig.json');
if (!isJavascript && !fs.existsSync(tsconfigJson)) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel: 'error'},
'Could not find a tsconfig.json file in your project. Did you delete it? Create a tsconfig.json in the root of your project. Copy the default file from https://github.com/remotion-dev/template-helloworld/blob/main/tsconfig.json.',
);
- Log.error('The root directory is:', remotionRoot);
+ Log.errorAdvanced(
+ {indent: false, logLevel: 'error'},
+ 'The root directory is:',
+ remotionRoot,
+ );
process.exit(1);
}
@@ -33,9 +38,12 @@ export const loadConfigFile = async (
packages: 'external',
});
if (result.errors.length > 0) {
- Log.error('Error in remotion.config.ts file');
+ Log.errorAdvanced(
+ {indent: false, logLevel: 'error'},
+ 'Error in remotion.config.ts file',
+ );
for (const err in result.errors) {
- Log.error(err);
+ Log.errorAdvanced({indent: false, logLevel: 'error'}, err);
}
process.exit(1);
diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.ts
index 9a4abe9c9c..46320d696c 100644
--- a/packages/cli/src/parse-command-line.ts
+++ b/packages/cli/src/parse-command-line.ts
@@ -173,8 +173,12 @@ export const parseCommandLine = () => {
if (parsedCli.log) {
if (!RenderInternals.isValidLogLevel(parsedCli.log)) {
- Log.error('Invalid `--log` value passed.');
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel: 'error'},
+ 'Invalid `--log` value passed.',
+ );
+ Log.errorAdvanced(
+ {indent: false, logLevel: 'error'},
`Accepted values: ${RenderInternals.logLevels
.map((l) => `'${l}'`)
.join(', ')}.`,
diff --git a/packages/cli/src/print-error.ts b/packages/cli/src/print-error.ts
index c76322316c..3741e6eb37 100644
--- a/packages/cli/src/print-error.ts
+++ b/packages/cli/src/print-error.ts
@@ -34,15 +34,15 @@ export const printError = async (err: Error, logLevel: LogLevel) => {
);
}
- printCodeFrameAndStack(symbolicated);
+ printCodeFrameAndStack(symbolicated, logLevel);
} catch (e) {
output.update(chalk.red(''), true);
- Log.error();
- Log.error(err.stack || err);
+ Log.errorAdvanced({indent: false, logLevel});
+ Log.errorAdvanced({indent: false, logLevel}, err.stack || err);
}
return;
}
- Log.error(err.stack || err);
+ Log.errorAdvanced({indent: false, logLevel}, err.stack || err);
};
diff --git a/packages/cli/src/render-flows/render.ts b/packages/cli/src/render-flows/render.ts
index 236e6a2bf8..f2b1c05e9d 100644
--- a/packages/cli/src/render-flows/render.ts
+++ b/packages/cli/src/render-flows/render.ts
@@ -344,6 +344,7 @@ export const renderVideoFlow = async ({
const absoluteOutputFile = getAndValidateAbsoluteOutputFile(
relativeOutputLocation,
overwrite,
+ logLevel,
);
const exists = existsSync(absoluteOutputFile);
diff --git a/packages/cli/src/render-flows/still.ts b/packages/cli/src/render-flows/still.ts
index a9ae36db14..5ffc83c0e0 100644
--- a/packages/cli/src/render-flows/still.ts
+++ b/packages/cli/src/render-flows/still.ts
@@ -239,6 +239,7 @@ export const renderStillFlow = async ({
const absoluteOutputLocation = getAndValidateAbsoluteOutputFile(
relativeOutputLocation,
overwrite,
+ logLevel,
);
const exists = existsSync(absoluteOutputLocation);
diff --git a/packages/cli/src/render-queue/queue.ts b/packages/cli/src/render-queue/queue.ts
index 5b95e31eaf..4000b10288 100644
--- a/packages/cli/src/render-queue/queue.ts
+++ b/packages/cli/src/render-queue/queue.ts
@@ -249,7 +249,11 @@ const processJobIfPossible = async ({
};
});
} catch (err) {
- Log.error(chalk.gray('╰─ '), chalk.red('Failed to render'));
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ chalk.gray('╰─ '),
+ chalk.red('Failed to render'),
+ );
updateJob(nextJob.id, (job) => {
return {
diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsx
index 446adb3e2d..1e646d2ec4 100644
--- a/packages/cli/src/render.tsx
+++ b/packages/cli/src/render.tsx
@@ -43,18 +43,26 @@ export const render = async (
} = findEntryPoint(args, remotionRoot, logLevel);
if (!file) {
- Log.error('No entry point specified. Pass more arguments:');
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'No entry point specified. Pass more arguments:',
+ );
+ Log.errorAdvanced(
+ {indent: false, logLevel},
' npx remotion render [entry-point] [composition-name] [out-name]',
);
- Log.error('Documentation: https://www.remotion.dev/docs/render');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Documentation: https://www.remotion.dev/docs/render',
+ );
process.exit(1);
}
const fullEntryPoint = convertEntryPointToServeUrl(file);
if (parsedCli.frame) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'--frame flag was passed to the `render` command. This flag only works with the `still` command. Did you mean `--frames`? See reference: https://www.remotion.dev/docs/cli/',
);
process.exit(1);
diff --git a/packages/cli/src/show-compositions-picker.ts b/packages/cli/src/show-compositions-picker.ts
index 1dff850e95..e18cd14ece 100644
--- a/packages/cli/src/show-compositions-picker.ts
+++ b/packages/cli/src/show-compositions-picker.ts
@@ -1,11 +1,12 @@
import {selectAsync} from './composition-prompts';
-import type {getCompositions} from '@remotion/renderer';
+import type {getCompositions, LogLevel} from '@remotion/renderer';
import {chalk} from './chalk';
type Await<T> = T extends PromiseLike<infer U> ? U : T;
export const showSingleCompositionsPicker = async (
validCompositions: Await<ReturnType<typeof getCompositions>>,
+ logLevel: LogLevel,
): Promise<{compositionId: string; reason: string}> => {
if (validCompositions.length === 1) {
const onlyComposition = validCompositions[0];
@@ -17,23 +18,27 @@ export const showSingleCompositionsPicker = async (
}
}
- const selectedComposition = (await selectAsync({
- message: 'Select composition:',
- optionsPerPage: 5,
- type: 'select',
- choices: validCompositions.map((comp) => {
- return {
- value: comp.id,
- title: chalk.bold(comp.id),
- };
- }),
- })) as string;
+ const selectedComposition = (await selectAsync(
+ {
+ message: 'Select composition:',
+ optionsPerPage: 5,
+ type: 'select',
+ choices: validCompositions.map((comp) => {
+ return {
+ value: comp.id,
+ title: chalk.bold(comp.id),
+ };
+ }),
+ },
+ logLevel,
+ )) as string;
return {compositionId: selectedComposition, reason: 'Selected'};
};
export const showMultiCompositionsPicker = async (
validCompositions: Await<ReturnType<typeof getCompositions>>,
+ logLevel: LogLevel,
): Promise<string[]> => {
if (validCompositions.length === 1) {
const onlyComposition = validCompositions[0];
@@ -42,18 +47,21 @@ export const showMultiCompositionsPicker = async (
}
}
- const selectedComposition = await selectAsync({
- message: 'Select compositions:',
- optionsPerPage: 5,
- type: 'multiselect',
- min: 1,
- choices: validCompositions.map((comp) => {
- return {
- value: comp.id,
- title: chalk.bold(comp.id),
- };
- }),
- });
+ const selectedComposition = await selectAsync(
+ {
+ message: 'Select compositions:',
+ optionsPerPage: 5,
+ type: 'multiselect',
+ min: 1,
+ choices: validCompositions.map((comp) => {
+ return {
+ value: comp.id,
+ title: chalk.bold(comp.id),
+ };
+ }),
+ },
+ logLevel,
+ );
return selectedComposition as string[];
};
diff --git a/packages/cli/src/still.ts b/packages/cli/src/still.ts
index 0e2917874f..f69c1d9909 100644
--- a/packages/cli/src/still.ts
+++ b/packages/cli/src/still.ts
@@ -30,18 +30,26 @@ export const still = async (
} = findEntryPoint(args, remotionRoot, logLevel);
if (!file) {
- Log.error('No entry point specified. Pass more arguments:');
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'No entry point specified. Pass more arguments:',
+ );
+ Log.errorAdvanced(
+ {indent: false, logLevel},
' npx remotion render [entry-point] [composition-name] [out-name]',
);
- Log.error('Documentation: https://www.remotion.dev/docs/render');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Documentation: https://www.remotion.dev/docs/render',
+ );
process.exit(1);
}
const fullEntryPoint = convertEntryPointToServeUrl(file);
if (parsedCli.frames) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'--frames flag was passed to the `still` command. This flag only works with the `render` command. Did you mean `--frame`? See reference: https://www.remotion.dev/docs/cli/',
);
process.exit(1);
diff --git a/packages/cli/src/studio.ts b/packages/cli/src/studio.ts
index 22a3e49895..c7f682800e 100644
--- a/packages/cli/src/studio.ts
+++ b/packages/cli/src/studio.ts
@@ -46,11 +46,16 @@ export const studioCommand = async (
);
if (!file) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'No Remotion entrypoint was found. Specify an additional argument manually:',
);
- Log.error(' npx remotion studio src/index.ts');
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ ' npx remotion studio src/index.ts',
+ );
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'See https://www.remotion.dev/docs/register-root for more information.',
);
process.exit(1);
diff --git a/packages/cli/src/versions.ts b/packages/cli/src/versions.ts
index 57e2ffc6f9..33d18e8506 100644
--- a/packages/cli/src/versions.ts
+++ b/packages/cli/src/versions.ts
@@ -143,7 +143,8 @@ export const versionsCommand = async (
if (installedVersions.length === 1) {
Log.info(`βœ… Great! All packages have the same version.`);
} else {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'Version mismatch: Not all Remotion packages have the same version.',
);
Log.info(
diff --git a/packages/cloudrun/src/api/check-if-service-exists.ts b/packages/cloudrun/src/api/check-if-service-exists.ts
index 8bf3fbc9d8..5cfeae1323 100644
--- a/packages/cloudrun/src/api/check-if-service-exists.ts
+++ b/packages/cloudrun/src/api/check-if-service-exists.ts
@@ -1,5 +1,6 @@
import type {protos} from '@google-cloud/run';
import {CliInternals} from '@remotion/cli';
+import type {LogLevel} from '@remotion/renderer';
import {Log} from '../cli/log';
import {generateServiceName} from '../shared/generate-service-name';
import {validateGcpRegion} from '../shared/validate-gcp-region';
@@ -12,6 +13,7 @@ export type CheckIfServiceExistsInput = {
cpuLimit: string;
timeoutSeconds: number;
region: string;
+ logLevel: LogLevel;
};
/**
@@ -29,6 +31,7 @@ export const checkIfServiceExists = async ({
timeoutSeconds,
projectID,
region,
+ logLevel,
}: CheckIfServiceExistsInput): Promise<
protos.google.cloud.run.v2.IService | undefined
> => {
@@ -55,7 +58,8 @@ export const checkIfServiceExists = async ({
}
} catch (e: any) {
if (e.code === 7) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
CliInternals.chalk.red(
`Issue with ${parent}. The project either doesn't exist, or you don't have access to it.
`,
diff --git a/packages/cloudrun/src/api/deploy-service.ts b/packages/cloudrun/src/api/deploy-service.ts
index fc910ca969..e44a9e7762 100644
--- a/packages/cloudrun/src/api/deploy-service.ts
+++ b/packages/cloudrun/src/api/deploy-service.ts
@@ -1,3 +1,4 @@
+import type {LogLevel} from '@remotion/renderer';
import {NoReactAPIs} from '@remotion/renderer/pure';
import {
DEFAULT_MAX_INSTANCES,
@@ -21,6 +22,7 @@ type InternalDeployServiceInput = {
maxInstances: number;
projectID: string;
region: string;
+ logLevel: LogLevel;
};
export type DeployServiceInput = {
performImageVersionValidation?: boolean;
@@ -29,6 +31,7 @@ export type DeployServiceInput = {
timeoutSeconds?: number;
minInstances?: number;
maxInstances?: number;
+ logLevel?: LogLevel;
projectID: string;
region: string;
};
@@ -49,6 +52,7 @@ const deployServiceRaw = async ({
maxInstances,
projectID,
region,
+ logLevel,
}: InternalDeployServiceInput): Promise<DeployServiceOutput> => {
validateGcpRegion(region);
validateProjectID(projectID);
@@ -66,6 +70,7 @@ const deployServiceRaw = async ({
timeoutSeconds,
projectID,
region,
+ logLevel,
});
const serviceName = generateServiceName({
@@ -134,6 +139,7 @@ export const deployService = ({
maxInstances,
projectID,
region,
+ logLevel,
}: DeployServiceInput): Promise<DeployServiceOutput> => {
return internalDeployService({
performImageVersionValidation,
@@ -144,5 +150,6 @@ export const deployService = ({
maxInstances: maxInstances ?? DEFAULT_MAX_INSTANCES,
projectID,
region,
+ logLevel: logLevel ?? 'info',
});
};
diff --git a/packages/cloudrun/src/cli/commands/permissions.ts b/packages/cloudrun/src/cli/commands/permissions.ts
index 5e3584ac68..b34cb2d722 100644
--- a/packages/cloudrun/src/cli/commands/permissions.ts
+++ b/packages/cloudrun/src/cli/commands/permissions.ts
@@ -1,4 +1,5 @@
import {CliInternals} from '@remotion/cli';
+import type {LogLevel} from '@remotion/renderer';
import {
logPermissionOutput,
testPermissions,
@@ -8,7 +9,7 @@ import {Log} from '../log';
export const PERMISSIONS_COMMAND = 'permissions';
-export const permissionsCommand = async () => {
+export const permissionsCommand = async (logLevel: LogLevel) => {
try {
Log.info(
CliInternals.chalk.blueBright(
@@ -24,7 +25,10 @@ export const permissionsCommand = async () => {
},
});
} catch (err) {
- Log.error('Did not have the required permissions on GCP:');
- Log.error(err);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Did not have the required permissions on GCP:',
+ );
+ Log.errorAdvanced({indent: false, logLevel}, err);
}
};
diff --git a/packages/cloudrun/src/cli/commands/render/helpers/renderArgsCheck.ts b/packages/cloudrun/src/cli/commands/render/helpers/renderArgsCheck.ts
index 57e3b039e3..b9cc03266a 100644
--- a/packages/cloudrun/src/cli/commands/render/helpers/renderArgsCheck.ts
+++ b/packages/cloudrun/src/cli/commands/render/helpers/renderArgsCheck.ts
@@ -25,7 +25,7 @@ export const renderArgsCheck = async (
let serveUrl = args[0];
if (!serveUrl) {
- Log.error('No serve URL passed.');
+ Log.errorAdvanced({indent: false, logLevel}, 'No serve URL passed.');
Log.info(
'Pass an additional argument specifying a URL where your Remotion project is hosted.',
);
@@ -64,7 +64,8 @@ export const renderArgsCheck = async (
let cloudRunUrl = parsedCloudrunCli['cloud-run-url'];
let serviceName = parsedCloudrunCli['service-name'];
if (cloudRunUrl && serviceName) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'Both a Cloud Run URL and a Service Name was provided. Specify only one.',
);
quit(1);
@@ -74,7 +75,10 @@ export const renderArgsCheck = async (
const services = await getServices({region, compatibleOnly: true});
if (services.length === 0) {
// TODO: Log if there is an incompatible service
- Log.error('No compatible services found. Please create a service first:');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'No compatible services found. Please create a service first:',
+ );
Log.info();
Log.info(
` ${BINARY_NAME} ${SERVICES_COMMAND} ${CLOUD_RUN_DEPLOY_SUBCOMMAND}`,
diff --git a/packages/cloudrun/src/cli/commands/render/index.ts b/packages/cloudrun/src/cli/commands/render/index.ts
index d29dc8e88a..54e1444b34 100644
--- a/packages/cloudrun/src/cli/commands/render/index.ts
+++ b/packages/cloudrun/src/cli/commands/render/index.ts
@@ -295,7 +295,7 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}
});
if (res.type === 'crash') {
- displayCrashLogs(res);
+ displayCrashLogs(res, logLevel);
} else if (res.type === 'success') {
renderProgress.doneIn = Date.now() - renderStart;
updateProgress();
diff --git a/packages/cloudrun/src/cli/commands/services/deploy.ts b/packages/cloudrun/src/cli/commands/services/deploy.ts
index b2357f955b..5df39b9c7b 100644
--- a/packages/cloudrun/src/cli/commands/services/deploy.ts
+++ b/packages/cloudrun/src/cli/commands/services/deploy.ts
@@ -1,4 +1,5 @@
import {CliInternals} from '@remotion/cli';
+import type {LogLevel} from '@remotion/renderer';
import {VERSION} from 'remotion/version';
import {displayServiceInfo, LEFT_COL} from '.';
import {internalDeployService} from '../../../api/deploy-service';
@@ -18,7 +19,7 @@ import {Log} from '../../log';
export const CLOUD_RUN_DEPLOY_SUBCOMMAND = 'deploy';
-export const cloudRunDeploySubcommand = async () => {
+export const cloudRunDeploySubcommand = async (logLevel: LogLevel) => {
const region = getGcpRegion();
const projectID = process.env.REMOTION_GCP_PROJECT_ID as string;
const memoryLimit = String(parsedCloudrunCli.memoryLimit ?? '2Gi');
@@ -58,7 +59,10 @@ ${[
await validateImageRemotionVersion();
if (projectID === undefined) {
- Log.error(`REMOTION_GCP_PROJECT_ID not found in the .env file.`);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ `REMOTION_GCP_PROJECT_ID not found in the .env file.`,
+ );
quit(0);
}
@@ -78,20 +82,30 @@ ${[
maxInstances: Number(maxInstances) ?? DEFAULT_MAX_INSTANCES,
projectID,
region,
+ logLevel,
});
if (!deployResult.fullName) {
- Log.error('full service name not returned from Cloud Run API.');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'full service name not returned from Cloud Run API.',
+ );
throw new Error(JSON.stringify(deployResult));
}
if (!deployResult.shortName) {
- Log.error('short service name not returned from Cloud Run API.');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'short service name not returned from Cloud Run API.',
+ );
throw new Error(JSON.stringify(deployResult));
}
if (!deployResult.alreadyExists && !deployResult.uri) {
- Log.error('service uri not returned from Cloud Run API.');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'service uri not returned from Cloud Run API.',
+ );
}
const consoleUrl = makeConsoleUrl(region, deployResult.shortName);
@@ -148,7 +162,8 @@ ${displayServiceInfo({
}
}
} catch (e) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
CliInternals.chalk.red(
`Failed to deploy service - ${generateServiceName({
memoryLimit,
diff --git a/packages/cloudrun/src/cli/commands/services/index.ts b/packages/cloudrun/src/cli/commands/services/index.ts
index f67fcfeaf4..db55dd0561 100644
--- a/packages/cloudrun/src/cli/commands/services/index.ts
+++ b/packages/cloudrun/src/cli/commands/services/index.ts
@@ -1,4 +1,5 @@
import {CliInternals} from '@remotion/cli';
+import type {LogLevel} from '@remotion/renderer';
import type {ServiceInfo} from '../../../api/get-service-info';
import {BINARY_NAME} from '../../../shared/constants';
import {quit} from '../../helpers/quit';
@@ -53,13 +54,13 @@ const printCloudRunHelp = () => {
);
};
-export const servicesCommand = (args: string[]) => {
+export const servicesCommand = (args: string[], logLevel: LogLevel) => {
if (args[0] === SERVICES_LS_SUBCOMMAND) {
return servicesLsCommand();
}
if (args[0] === SERVICES_RM_SUBCOMMAND) {
- return servicesRmCommand(args.slice(1));
+ return servicesRmCommand(args.slice(1), logLevel);
}
if (args[0] === SERVICES_RMALL_SUBCOMMAND) {
@@ -67,11 +68,14 @@ export const servicesCommand = (args: string[]) => {
}
if (args[0] === CLOUD_RUN_DEPLOY_SUBCOMMAND) {
- return cloudRunDeploySubcommand();
+ return cloudRunDeploySubcommand(logLevel);
}
if (args[0]) {
- Log.error(`Subcommand ${args[0]} not found.`);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ `Subcommand ${args[0]} not found.`,
+ );
printCloudRunHelp();
quit(1);
}
diff --git a/packages/cloudrun/src/cli/commands/services/rm.ts b/packages/cloudrun/src/cli/commands/services/rm.ts
index 286a53fdf5..5fa02082e8 100644
--- a/packages/cloudrun/src/cli/commands/services/rm.ts
+++ b/packages/cloudrun/src/cli/commands/services/rm.ts
@@ -1,4 +1,5 @@
import {CliInternals} from '@remotion/cli';
+import type {LogLevel} from '@remotion/renderer';
import {deleteService} from '../../../api/delete-service';
import {getServiceInfo} from '../../../api/get-service-info';
import {BINARY_NAME} from '../../../shared/constants';
@@ -11,10 +12,11 @@ import {SERVICES_LS_SUBCOMMAND} from './ls';
export const SERVICES_RM_SUBCOMMAND = 'rm';
-export const servicesRmCommand = async (args: string[]) => {
+export const servicesRmCommand = async (args: string[], logLevel: LogLevel) => {
if (args.length === 0) {
- Log.error('No service name passed.');
- Log.error(
+ Log.errorAdvanced({indent: false, logLevel}, 'No service name passed.');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'Pass another argument which is the name of the service you would like to remove.',
);
Log.info(
diff --git a/packages/cloudrun/src/cli/commands/sites/create.ts b/packages/cloudrun/src/cli/commands/sites/create.ts
index bcb5adcb19..ded8490d26 100644
--- a/packages/cloudrun/src/cli/commands/sites/create.ts
+++ b/packages/cloudrun/src/cli/commands/sites/create.ts
@@ -36,7 +36,7 @@ export const sitesCreateSubcommand = async (
logLevel,
);
if (!file) {
- Log.error('No entry file passed.');
+ Log.errorAdvanced({indent: false, logLevel}, 'No entry file passed.');
Log.info(
'Pass an additional argument specifying the entry file of your Remotion project:',
);
@@ -55,14 +55,16 @@ export const sitesCreateSubcommand = async (
);
if (!existsSync(file)) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`No file exists at ${file}. Make sure the path exists and try again.`,
);
quit(1);
}
if (lstatSync(file).isDirectory()) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`You passed a path ${file} but it is a directory. Pass a file instead.`,
);
quit(1);
diff --git a/packages/cloudrun/src/cli/commands/sites/index.ts b/packages/cloudrun/src/cli/commands/sites/index.ts
index b6cbd8a97e..aa78bcde45 100644
--- a/packages/cloudrun/src/cli/commands/sites/index.ts
+++ b/packages/cloudrun/src/cli/commands/sites/index.ts
@@ -63,7 +63,7 @@ export const sitesCommand = (
}
if (args[0] === SITES_RM_COMMAND) {
- return sitesRmSubcommand(args.slice(1));
+ return sitesRmSubcommand(args.slice(1), logLevel);
}
if (args[0] === SITES_RMALL_COMMAND) {
@@ -75,7 +75,10 @@ export const sitesCommand = (
}
if (args[0]) {
- Log.error(`Subcommand ${args[0]} not found.`);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ `Subcommand ${args[0]} not found.`,
+ );
printSitesHelp();
quit(1);
}
diff --git a/packages/cloudrun/src/cli/commands/sites/rm.ts b/packages/cloudrun/src/cli/commands/sites/rm.ts
index 9999c4a249..4ffa9ec9aa 100644
--- a/packages/cloudrun/src/cli/commands/sites/rm.ts
+++ b/packages/cloudrun/src/cli/commands/sites/rm.ts
@@ -1,4 +1,5 @@
import {CliInternals} from '@remotion/cli';
+import type {LogLevel} from '@remotion/renderer';
import {displaySiteInfo, SITES_COMMAND} from '.';
import {deleteSite} from '../../../api/delete-site';
import {getSites} from '../../../api/get-sites';
@@ -11,12 +12,14 @@ import {SITES_LS_SUBCOMMAND} from './ls';
export const SITES_RM_COMMAND = 'rm';
-export const sitesRmSubcommand = async (args: string[]) => {
+export const sitesRmSubcommand = async (args: string[], logLevel: LogLevel) => {
if (args.length === 0) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'No site name was passed. Run the command again and pass another argument <site-name>.',
);
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`To get a list of sites, run \`${BINARY_NAME} ${SITES_COMMAND} ${SITES_LS_SUBCOMMAND}\``,
);
quit(1);
diff --git a/packages/cloudrun/src/cli/commands/still.ts b/packages/cloudrun/src/cli/commands/still.ts
index 8b911e0a95..27af64e8dc 100644
--- a/packages/cloudrun/src/cli/commands/still.ts
+++ b/packages/cloudrun/src/cli/commands/still.ts
@@ -204,7 +204,7 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}
delayRenderTimeoutInMilliseconds: puppeteerTimeout,
});
if (res.type === 'crash') {
- displayCrashLogs(res);
+ displayCrashLogs(res, logLevel);
} else if (res.type === 'success') {
doneIn = Date.now() - renderStart;
updateProgress(true);
diff --git a/packages/cloudrun/src/cli/helpers/cloudrun-crash-logs.ts b/packages/cloudrun/src/cli/helpers/cloudrun-crash-logs.ts
index a4d13614d3..a5167c7b8f 100644
--- a/packages/cloudrun/src/cli/helpers/cloudrun-crash-logs.ts
+++ b/packages/cloudrun/src/cli/helpers/cloudrun-crash-logs.ts
@@ -1,4 +1,5 @@
import {CliInternals} from '@remotion/cli';
+import type {LogLevel} from '@remotion/renderer';
import {extractMemoryFromURL} from '../../api/helpers/extract-mem-from-url';
import {extractTimeoutFromURL} from '../../api/helpers/extract-time-from-url';
import {getCloudLoggingClient} from '../../api/helpers/get-cloud-logging-client';
@@ -6,7 +7,10 @@ import {getProjectId} from '../../functions/helpers/is-in-cloud-task';
import type {CloudRunCrashResponse} from '../../functions/helpers/payloads';
import {Log} from '../log';
-export const displayCrashLogs = async (res: CloudRunCrashResponse) => {
+export const displayCrashLogs = async (
+ res: CloudRunCrashResponse,
+ logLevel: LogLevel,
+) => {
let timeoutPreMsg = '';
const timeout = extractTimeoutFromURL(res.cloudRunEndpoint);
@@ -22,7 +26,8 @@ export const displayCrashLogs = async (res: CloudRunCrashResponse) => {
)} seconds, below the timeout of ${timeout} seconds.\n`;
}
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`Error rendering on Cloud Run. The Cloud Run service did not return a response.\n
${timeoutPreMsg}The crash may be due to the service exceeding its memory limit of ${memoryLimit}.
Full logs are available at https://console.cloud.google.com/run?project=${getProjectId()}\n`,
diff --git a/packages/cloudrun/src/cli/index.ts b/packages/cloudrun/src/cli/index.ts
index a2415956b7..b19bc3edfe 100644
--- a/packages/cloudrun/src/cli/index.ts
+++ b/packages/cloudrun/src/cli/index.ts
@@ -31,7 +31,7 @@ const matchCommand = (
}
if (args[0] === SERVICES_COMMAND) {
- return servicesCommand(args.slice(1));
+ return servicesCommand(args.slice(1), logLevel);
}
if (args[0] === SITES_COMMAND) {
@@ -43,7 +43,7 @@ const matchCommand = (
}
if (args[0] === PERMISSIONS_COMMAND) {
- return permissionsCommand();
+ return permissionsCommand(logLevel);
}
if (args[0] === 'deploy') {
@@ -51,7 +51,7 @@ const matchCommand = (
Log.info(`Did you mean "service deploy"?`);
}
- Log.error(`Command ${args[0]} not found.`);
+ Log.errorAdvanced({indent: false, logLevel}, `Command ${args[0]} not found.`);
printHelp();
quit(1);
};
diff --git a/packages/lambda/src/cli/commands/compositions/index.ts b/packages/lambda/src/cli/commands/compositions/index.ts
index 5b3c468903..357b93614e 100644
--- a/packages/lambda/src/cli/commands/compositions/index.ts
+++ b/packages/lambda/src/cli/commands/compositions/index.ts
@@ -22,7 +22,7 @@ export const compositionsCommand = async (
const serveUrl = args[0];
if (!serveUrl) {
- Log.error('No serve URL passed.');
+ Log.errorAdvanced({indent: false, logLevel}, 'No serve URL passed.');
Log.info(
'Pass an additional argument specifying a URL where your Remotion project is hosted.',
);
diff --git a/packages/lambda/src/cli/commands/functions/index.ts b/packages/lambda/src/cli/commands/functions/index.ts
index 09e9ac84fe..15b9290bba 100644
--- a/packages/lambda/src/cli/commands/functions/index.ts
+++ b/packages/lambda/src/cli/commands/functions/index.ts
@@ -59,7 +59,10 @@ export const functionsCommand = (args: string[], logLevel: LogLevel) => {
}
if (args[0]) {
- CliInternals.Log.error(`Subcommand ${args[0]} not found.`);
+ CliInternals.Log.errorAdvanced(
+ {indent: false, logLevel},
+ `Subcommand ${args[0]} not found.`,
+ );
printFunctionsHelp();
quit(1);
}
diff --git a/packages/lambda/src/cli/commands/functions/rm.ts b/packages/lambda/src/cli/commands/functions/rm.ts
index 22c0662a55..f684cb4235 100644
--- a/packages/lambda/src/cli/commands/functions/rm.ts
+++ b/packages/lambda/src/cli/commands/functions/rm.ts
@@ -18,8 +18,9 @@ export const functionsRmCommand = async (
logLevel: LogLevel,
) => {
if (args.length === 0) {
- Log.error('No function name passed.');
- Log.error(
+ Log.errorAdvanced({indent: false, logLevel}, 'No function name passed.');
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'Pass another argument which is the name of the function you would like to remove.',
);
Log.info(
diff --git a/packages/lambda/src/cli/commands/policies/policies.ts b/packages/lambda/src/cli/commands/policies/policies.ts
index d3756f4b70..08eaa02769 100644
--- a/packages/lambda/src/cli/commands/policies/policies.ts
+++ b/packages/lambda/src/cli/commands/policies/policies.ts
@@ -1,4 +1,5 @@
import {CliInternals} from '@remotion/cli';
+import type {LogLevel} from '@remotion/renderer';
import {BINARY_NAME} from '../../../shared/constants';
import {quit} from '../../helpers/quit';
import {Log} from '../../log';
@@ -35,7 +36,7 @@ const printPoliciesHelp = () => {
);
};
-export const policiesCommand = (args: string[]) => {
+export const policiesCommand = (args: string[], logLevel: LogLevel) => {
if (args[0] === USER_SUBCOMMAND) {
return userSubcommand();
}
@@ -45,11 +46,14 @@ export const policiesCommand = (args: string[]) => {
}
if (args[0] === VALIDATE_SUBCOMMAND) {
- return validateSubcommand();
+ return validateSubcommand(logLevel);
}
if (args[0]) {
- Log.error(`Subcommand ${args[0]} not found.`);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ `Subcommand ${args[0]} not found.`,
+ );
printPoliciesHelp();
quit(1);
}
diff --git a/packages/lambda/src/cli/commands/policies/validate.ts b/packages/lambda/src/cli/commands/policies/validate.ts
index fb0084f93b..138a8f283c 100644
--- a/packages/lambda/src/cli/commands/policies/validate.ts
+++ b/packages/lambda/src/cli/commands/policies/validate.ts
@@ -1,3 +1,4 @@
+import type {LogLevel} from '@remotion/renderer';
import {
logPermissionOutput,
simulatePermissions,
@@ -7,7 +8,7 @@ import {Log} from '../../log';
export const VALIDATE_SUBCOMMAND = 'validate';
-export const validateSubcommand = async () => {
+export const validateSubcommand = async (logLevel: LogLevel) => {
try {
await simulatePermissions({
region: getAwsRegion(),
@@ -16,7 +17,10 @@ export const validateSubcommand = async () => {
},
});
} catch (err) {
- Log.error('Did not have the required permissions on AWS:');
- Log.error(err);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Did not have the required permissions on AWS:',
+ );
+ Log.errorAdvanced({indent: false, logLevel}, err);
}
};
diff --git a/packages/lambda/src/cli/commands/quotas/increase.ts b/packages/lambda/src/cli/commands/quotas/increase.ts
index 2cf2348f20..fc4051c4b3 100644
--- a/packages/lambda/src/cli/commands/quotas/increase.ts
+++ b/packages/lambda/src/cli/commands/quotas/increase.ts
@@ -76,7 +76,8 @@ export const quotasIncreaseCommand = async (logLevel: LogLevel) => {
const defaultConcurrency = defaultConcurrencyLimit.Quota?.Value as number;
const increaseRecommended = concurrencyCurrent <= defaultConcurrency;
if (!increaseRecommended && !forceFlagProvided) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`Current limit of ${concurrencyCurrent} is already increased over the default (${defaultConcurrency}).`,
);
Log.info('You can force the increase with the --force flag.');
@@ -110,10 +111,12 @@ export const quotasIncreaseCommand = async (logLevel: LogLevel) => {
);
} catch (err) {
if ((err as Error).name === 'DependencyAccessDeniedException') {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'Could not request increase because this is a sub-account of another AWS account.',
);
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`Please go to ${makeQuotaUrl({
quotaId: LAMBDA_CONCURRENCY_LIMIT_QUOTA,
region,
diff --git a/packages/lambda/src/cli/commands/quotas/index.ts b/packages/lambda/src/cli/commands/quotas/index.ts
index cf5369fc51..25bfef46fd 100644
--- a/packages/lambda/src/cli/commands/quotas/index.ts
+++ b/packages/lambda/src/cli/commands/quotas/index.ts
@@ -28,6 +28,9 @@ export const quotasCommand = (args: string[], logLevel: LogLevel) => {
return quotasIncreaseCommand(logLevel);
}
- CliInternals.Log.error('Subcommand ' + args[0] + ' not found.');
+ CliInternals.Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Subcommand ' + args[0] + ' not found.',
+ );
printHelp();
};
diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.ts
index 41b8765bb8..34c88d68d6 100644
--- a/packages/lambda/src/cli/commands/render/render.ts
+++ b/packages/lambda/src/cli/commands/render/render.ts
@@ -65,7 +65,7 @@ export const renderCommand = async (
) => {
const serveUrl = args[0];
if (!serveUrl) {
- Log.error('No serve URL passed.');
+ Log.errorAdvanced({indent: false, logLevel}, 'No serve URL passed.');
Log.info(
'Pass an additional argument specifying a URL where your Remotion project is hosted.',
);
@@ -460,7 +460,7 @@ export const renderCommand = async (
}
if (newStatus.fatalErrorEncountered) {
- Log.error('\n');
+ Log.errorAdvanced({indent: false, logLevel}, '\n');
const uniqueErrors: EnhancedErrorInfo[] = [];
for (const err of newStatus.errors) {
if (uniqueErrors.find((e) => e.stack === err.stack)) {
@@ -469,7 +469,7 @@ export const renderCommand = async (
uniqueErrors.push(err);
if (err.explanation) {
- Log.error(err.explanation);
+ Log.errorAdvanced({indent: false, logLevel}, err.explanation);
}
const frames = RenderInternals.parseStack(err.stack.split('\n'));
diff --git a/packages/lambda/src/cli/commands/sites/create.ts b/packages/lambda/src/cli/commands/sites/create.ts
index 92f22746d5..84b2541dff 100644
--- a/packages/lambda/src/cli/commands/sites/create.ts
+++ b/packages/lambda/src/cli/commands/sites/create.ts
@@ -37,7 +37,7 @@ export const sitesCreateSubcommand = async (
logLevel,
);
if (!file) {
- Log.error('No entry file passed.');
+ Log.errorAdvanced({indent: false, logLevel}, 'No entry file passed.');
Log.info(
'Pass an additional argument specifying the entry file of your Remotion project:',
);
diff --git a/packages/lambda/src/cli/commands/sites/index.ts b/packages/lambda/src/cli/commands/sites/index.ts
index 1ec34c9569..651d017eff 100644
--- a/packages/lambda/src/cli/commands/sites/index.ts
+++ b/packages/lambda/src/cli/commands/sites/index.ts
@@ -53,7 +53,7 @@ export const sitesCommand = (
}
if (args[0] === SITES_RM_COMMAND) {
- return sitesRmSubcommand(args.slice(1));
+ return sitesRmSubcommand(args.slice(1), logLevel);
}
if (args[0] === SITES_RMALL_COMMAND) {
@@ -65,7 +65,10 @@ export const sitesCommand = (
}
if (args[0]) {
- CliInternals.Log.error(`Subcommand ${args[0]} not found.`);
+ CliInternals.Log.errorAdvanced(
+ {indent: false, logLevel},
+ `Subcommand ${args[0]} not found.`,
+ );
printSitesHelp();
quit(1);
}
diff --git a/packages/lambda/src/cli/commands/sites/rm.ts b/packages/lambda/src/cli/commands/sites/rm.ts
index 6c66a10706..3c63c28844 100644
--- a/packages/lambda/src/cli/commands/sites/rm.ts
+++ b/packages/lambda/src/cli/commands/sites/rm.ts
@@ -1,4 +1,5 @@
import {CliInternals} from '@remotion/cli';
+import type {LogLevel} from '@remotion/renderer';
import {deleteSite} from '../../../api/delete-site';
import {internalGetOrCreateBucket} from '../../../api/get-or-create-bucket';
import {getSites} from '../../../api/get-sites';
@@ -9,9 +10,10 @@ import {quit} from '../../helpers/quit';
import {Log} from '../../log';
export const SITES_RM_COMMAND = 'rm';
-export const sitesRmSubcommand = async (args: string[]) => {
+export const sitesRmSubcommand = async (args: string[], logLevel: LogLevel) => {
if (args.length === 0) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'No site name was passed. Run the command again and pass another argument <site-name>.',
);
quit(1);
@@ -41,7 +43,8 @@ export const sitesRmSubcommand = async (args: string[]) => {
for (const siteName of args) {
const site = deployedSites.sites.find((s) => s.id === siteName.trim());
if (!site) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`No site ${siteName.trim()} was found in your bucket ${bucketName}.`,
);
return quit(1);
diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.ts
index 12bb840d26..c9a5647146 100644
--- a/packages/lambda/src/cli/commands/still.ts
+++ b/packages/lambda/src/cli/commands/still.ts
@@ -39,7 +39,7 @@ export const stillCommand = async (
const serveUrl = args[0];
if (!serveUrl) {
- Log.error('No serve URL passed.');
+ Log.errorAdvanced({indent: false, logLevel}, 'No serve URL passed.');
Log.info(
'Pass an additional argument specifying a URL where your Remotion project is hosted.',
);
diff --git a/packages/lambda/src/cli/helpers/find-function-name.ts b/packages/lambda/src/cli/helpers/find-function-name.ts
index 417a315602..5fc0e08c0e 100644
--- a/packages/lambda/src/cli/helpers/find-function-name.ts
+++ b/packages/lambda/src/cli/helpers/find-function-name.ts
@@ -25,11 +25,13 @@ export const findFunctionName = async (logLevel: LogLevel) => {
};
if (lambdasWithMatchingVersion.length === 0) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`No Lambda functions with version ${VERSION} found in your account.`,
);
if (remotionLambdas.length > 0) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'Other functions were found, but are not compatible with this version of the CLI.',
);
}
@@ -50,7 +52,8 @@ export const findFunctionName = async (logLevel: LogLevel) => {
(l) => l.functionName === parsedLambdaCli['function-name'],
);
if (lambdasWithMatchingVersion.length === 0) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`No Lambda function with name "${parsedLambdaCli['function-name']}" and version ${VERSION} found in your account.`,
);
Log.infoAdvanced(logOptions);
@@ -80,7 +83,8 @@ export const findFunctionName = async (logLevel: LogLevel) => {
quit(1);
}
} else {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'More than 1 lambda function found in your account. Unsure which one to use.',
);
Log.infoAdvanced(logOptions);
diff --git a/packages/lambda/src/cli/helpers/get-webhook-custom-data.ts b/packages/lambda/src/cli/helpers/get-webhook-custom-data.ts
index b87e97bb89..780dbe0b3e 100644
--- a/packages/lambda/src/cli/helpers/get-webhook-custom-data.ts
+++ b/packages/lambda/src/cli/helpers/get-webhook-custom-data.ts
@@ -26,11 +26,13 @@ export const getWebhookCustomData = (
return JSON.parse(webhookFlag);
} catch (err) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`You passed --${flagName} but it was neither valid JSON nor a file path to a valid JSON file. Provided value: ${webhookFlag}`,
);
Log.info('Got the following value:', webhookFlag);
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'Check that your input is parseable using `JSON.parse` and try again.',
);
if (os.platform() === 'win32') {
diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.ts
index bf67a44a19..3c645ab0ab 100644
--- a/packages/lambda/src/cli/index.ts
+++ b/packages/lambda/src/cli/index.ts
@@ -77,7 +77,7 @@ const matchCommand = (
}
if (args[0] === POLICIES_COMMAND) {
- return policiesCommand(args.slice(1));
+ return policiesCommand(args.slice(1), logLevel);
}
if (args[0] === REGIONS_COMMAND) {
@@ -117,7 +117,7 @@ const matchCommand = (
Log.info(`Did you mean "functions deploy"?`);
}
- Log.error(`Command ${args[0]} not found.`);
+ Log.errorAdvanced({indent: false, logLevel}, `Command ${args[0]} not found.`);
printHelp();
quit(1);
};
@@ -138,7 +138,8 @@ export const executeCommand = async (
)
) {
if (parsedLambdaCli['custom-role-arn']) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`
The role "${parsedLambdaCli['custom-role-arn']}" does not exist or has the wrong policy assigned to it. Do either:
- Remove the "--custom-role-arn" parameter and set up Remotion Lambda according to the setup guide
@@ -149,7 +150,8 @@ export const executeCommand = async (
);
}
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`
The role "${ROLE_NAME}" does not exist in your AWS account or has the wrong policy assigned to it. Common reasons:
- The name of the role is not "${ROLE_NAME}"
@@ -161,7 +163,8 @@ Revisit ${DOCS_URL}/docs/lambda/setup and make sure you set up the role and role
}
if (error.stack?.includes('AccessDenied')) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`
AWS returned an "AccessDenied" error message meaning a permission is missing. Read the permissions troubleshooting page: ${DOCS_URL}/docs/lambda/troubleshooting/permissions. The original error message is:
`.trim(),
@@ -169,7 +172,8 @@ AWS returned an "AccessDenied" error message meaning a permission is missing. Re
}
if (error.stack?.includes('TooManyRequestsException')) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`
AWS returned an "TooManyRequestsException" error message which could mean you reached the concurrency limit of AWS Lambda. You can increase the limit - read this troubleshooting page: ${DOCS_URL}/docs/lambda/troubleshooting/rate-limit. The original error message is:
`.trim(),
@@ -188,13 +192,15 @@ AWS returned an "TooManyRequestsException" error message which could mean you re
process.env.AWS_ACCESS_KEY_ID &&
!process.env.AWS_ACCESS_KEY_ID.startsWith('AKI');
if (keyButDoesntStartWithAki || pureKeyButDoesntStartWithAki) {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`
AWS returned an error message "The security token included in the request is invalid". A possible reason is that your AWS Access key ID is set but doesn't start with "AKI", which it usually should. The original message is:
`,
);
} else {
- Log.error(
+ Log.errorAdvanced(
+ {indent: false, logLevel},
`
AWS returned an error message "The security token included in the request is invalid". A possible reason for this is that you did not enable the region in your AWS account under "Account". The original message is:
`,
diff --git a/packages/lambda/src/functions/helpers/merge-chunks.ts b/packages/lambda/src/functions/helpers/merge-chunks.ts
index eacb9fd2fd..6065b497b8 100644
--- a/packages/lambda/src/functions/helpers/merge-chunks.ts
+++ b/packages/lambda/src/functions/helpers/merge-chunks.ts
@@ -107,7 +107,11 @@ export const mergeChunksAndFinishRender = async (options: {
};
const onErrors = (errors: EnhancedErrorInfo[]) => {
- RenderInternals.Log.error('Found Errors', errors);
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel: options.logLevel},
+ 'Found Errors',
+ errors,
+ );
const firstError = errors[0];
if (firstError.chunk !== null) {
diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.ts
index 0ba4a15621..3aea5e2ecf 100644
--- a/packages/lambda/src/functions/launch.ts
+++ b/packages/lambda/src/functions/launch.ts
@@ -478,10 +478,14 @@ export const launchHandler = async (
throw err;
}
- RenderInternals.Log.error(
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel: params.logLevel},
'Failed to invoke additional function to merge videos:',
);
- RenderInternals.Log.error(err);
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel: params.logLevel},
+ err,
+ );
await writeLambdaError({
bucketName: params.bucketName,
@@ -513,25 +517,34 @@ export const launchHandler = async (
}
try {
- await invokeWebhook({
- url: params.webhook.url,
- secret: params.webhook.secret,
- payload: {
- type: 'timeout',
- renderId: params.renderId,
- expectedBucketOwner: options.expectedBucketOwner,
- bucketName: params.bucketName,
- customData: params.webhook.customData ?? null,
+ await invokeWebhook(
+ {
+ url: params.webhook.url,
+ secret: params.webhook.secret,
+ payload: {
+ type: 'timeout',
+ renderId: params.renderId,
+ expectedBucketOwner: options.expectedBucketOwner,
+ bucketName: params.bucketName,
+ customData: params.webhook.customData ?? null,
+ },
},
- });
+ params.logLevel,
+ );
webhookInvoked = true;
} catch (err) {
if (process.env.NODE_ENV === 'test') {
throw err;
}
- RenderInternals.Log.error('Failed to invoke webhook:');
- RenderInternals.Log.error(err);
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel: params.logLevel},
+ 'Failed to invoke webhook:',
+ );
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel: params.logLevel},
+ err,
+ );
await writeLambdaError({
bucketName: params.bucketName,
@@ -586,22 +599,25 @@ export const launchHandler = async (
}
try {
- await invokeWebhook({
- url: params.webhook.url,
- secret: params.webhook.secret,
- payload: {
- type: 'success',
- renderId: params.renderId,
- expectedBucketOwner: options.expectedBucketOwner,
- bucketName: params.bucketName,
- customData: params.webhook.customData ?? null,
- outputUrl: postRenderData.outputFile,
- lambdaErrors: postRenderData.errors,
- outputFile: postRenderData.outputFile,
- timeToFinish: postRenderData.timeToFinish,
- costs: postRenderData.cost,
+ await invokeWebhook(
+ {
+ url: params.webhook.url,
+ secret: params.webhook.secret,
+ payload: {
+ type: 'success',
+ renderId: params.renderId,
+ expectedBucketOwner: options.expectedBucketOwner,
+ bucketName: params.bucketName,
+ customData: params.webhook.customData ?? null,
+ outputUrl: postRenderData.outputFile,
+ lambdaErrors: postRenderData.errors,
+ outputFile: postRenderData.outputFile,
+ timeToFinish: postRenderData.timeToFinish,
+ costs: postRenderData.cost,
+ },
},
- });
+ params.logLevel,
+ );
webhookInvoked = true;
} catch (err) {
if (process.env.NODE_ENV === 'test') {
@@ -626,8 +642,14 @@ export const launchHandler = async (
renderId: params.renderId,
expectedBucketOwner: options.expectedBucketOwner,
});
- RenderInternals.Log.error('Failed to invoke webhook:');
- RenderInternals.Log.error(err);
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel: params.logLevel},
+ 'Failed to invoke webhook:',
+ );
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel: params.logLevel},
+ err,
+ );
}
return {
@@ -638,7 +660,11 @@ export const launchHandler = async (
throw err;
}
- RenderInternals.Log.error('Error occurred', err);
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel: params.logLevel},
+ 'Error occurred',
+ err,
+ );
await writeLambdaError({
bucketName: params.bucketName,
errorInfo: {
@@ -657,27 +683,33 @@ export const launchHandler = async (
expectedBucketOwner: options.expectedBucketOwner,
renderId: params.renderId,
});
- RenderInternals.Log.error('Wrote error to S3');
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel: params.logLevel},
+ 'Wrote error to S3',
+ );
clearTimeout(webhookDueToTimeout);
if (params.webhook && !webhookInvoked) {
try {
- await invokeWebhook({
- url: params.webhook.url,
- secret: params.webhook.secret,
- payload: {
- type: 'error',
- renderId: params.renderId,
- expectedBucketOwner: options.expectedBucketOwner,
- bucketName: params.bucketName,
- customData: params.webhook.customData ?? null,
- errors: [err as Error].map((e) => ({
- message: e.message,
- name: e.name as string,
- stack: e.stack as string,
- })),
+ await invokeWebhook(
+ {
+ url: params.webhook.url,
+ secret: params.webhook.secret,
+ payload: {
+ type: 'error',
+ renderId: params.renderId,
+ expectedBucketOwner: options.expectedBucketOwner,
+ bucketName: params.bucketName,
+ customData: params.webhook.customData ?? null,
+ errors: [err as Error].map((e) => ({
+ message: e.message,
+ name: e.name as string,
+ stack: e.stack as string,
+ })),
+ },
},
- });
+ params.logLevel,
+ );
webhookInvoked = true;
} catch (error) {
if (process.env.NODE_ENV === 'test') {
@@ -702,8 +734,14 @@ export const launchHandler = async (
renderId: params.renderId,
expectedBucketOwner: options.expectedBucketOwner,
});
- RenderInternals.Log.error('Failed to invoke webhook:');
- RenderInternals.Log.error(error);
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel: params.logLevel},
+ 'Failed to invoke webhook:',
+ );
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel: params.logLevel},
+ error,
+ );
}
}
diff --git a/packages/lambda/src/shared/invoke-webhook.ts b/packages/lambda/src/shared/invoke-webhook.ts
index 2016b7aae8..285144549b 100644
--- a/packages/lambda/src/shared/invoke-webhook.ts
+++ b/packages/lambda/src/shared/invoke-webhook.ts
@@ -1,3 +1,4 @@
+import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import https from 'https';
import * as Crypto from 'node:crypto';
@@ -128,6 +129,7 @@ function exponentialBackoff(errorCount: number): number {
export const invokeWebhook = async (
options: InvokeWebhookOptions,
+ logLevel: LogLevel,
retries = 2,
errors = 0,
): Promise<void> => {
@@ -138,9 +140,18 @@ export const invokeWebhook = async (
throw err;
}
- RenderInternals.Log.error('Could not send webhook due to error:');
- RenderInternals.Log.error((err as Error).stack);
- RenderInternals.Log.error(`Retrying in ${exponentialBackoff(errors)}ms.`);
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Could not send webhook due to error:',
+ );
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel},
+ (err as Error).stack,
+ );
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel},
+ `Retrying in ${exponentialBackoff(errors)}ms.`,
+ );
await new Promise<void>((resolve) => {
setTimeout(() => {
@@ -148,6 +159,6 @@ export const invokeWebhook = async (
}, exponentialBackoff(errors));
});
- return invokeWebhook(options, retries - 1, errors + 1);
+ return invokeWebhook(options, logLevel, retries - 1, errors + 1);
}
};
diff --git a/packages/renderer/src/repro.ts b/packages/renderer/src/repro.ts
index b311679f0c..911ff40b23 100644
--- a/packages/renderer/src/repro.ts
+++ b/packages/renderer/src/repro.ts
@@ -179,8 +179,11 @@ const reproWriter = (name: string): ReproWriter => {
});
});
} catch (error) {
- Log.error(`repro render success error:`);
- Log.error(error);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ `repro render success error:`,
+ );
+ Log.errorAdvanced({indent: false, logLevel}, error);
reject(error);
}
});
diff --git a/packages/studio-server/src/helpers/open-in-editor.ts b/packages/studio-server/src/helpers/open-in-editor.ts
index e9e1b9d062..b74e6c4355 100644
--- a/packages/studio-server/src/helpers/open-in-editor.ts
+++ b/packages/studio-server/src/helpers/open-in-editor.ts
@@ -10,6 +10,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
+import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import type {ChildProcess} from 'node:child_process';
import child_process, {exec} from 'node:child_process';
@@ -450,12 +451,14 @@ export async function launchEditor({
fileName,
lineNumber,
vsCodeNewWindow,
+ logLevel,
}: {
fileName: string;
lineNumber: number;
colNumber: number;
editor: ProcessAndCommand;
vsCodeNewWindow: boolean;
+ logLevel: LogLevel;
}): Promise<boolean> {
if (!fs.existsSync(fileName)) {
return false;
@@ -500,16 +503,20 @@ export async function launchEditor({
process.platform === 'win32' &&
!WINDOWS_FILE_NAME_WHITELIST.test(fileName.trim())
) {
- Log.error();
- Log.error('Could not open ' + path.basename(fileName) + ' in the editor.');
- Log.error();
- Log.error(
+ Log.errorAdvanced({indent: false, logLevel});
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Could not open ' + path.basename(fileName) + ' in the editor.',
+ );
+ Log.errorAdvanced({indent: false, logLevel});
+ Log.errorAdvanced(
+ {indent: false, logLevel},
'When running on Windows, file names are checked against a whitelist ' +
'to protect against remote code execution attacks. File names may ' +
'consist only of alphanumeric characters (all languages), periods, ' +
'dashes, slashes, and underscores.',
);
- Log.error();
+ Log.errorAdvanced({indent: false, logLevel});
return false;
}
@@ -571,12 +578,20 @@ export async function launchEditor({
_childProcess = null;
if (errorCode) {
- Log.error(`Process exited with code ${errorCode}`);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ `Process exited with code ${errorCode}`,
+ );
}
});
_childProcess.on('error', (error) => {
- Log.error('Error opening file in editor', fileName, error.message);
+ Log.errorAdvanced(
+ {indent: false, logLevel},
+ 'Error opening file in editor',
+ fileName,
+ error.message,
+ );
reject(new Error('Error opening file in editor'));
});
resolve(true);
diff --git a/packages/studio-server/src/preview-server/start-server.ts b/packages/studio-server/src/preview-server/start-server.ts
index b7f87e2072..896eecb040 100644
--- a/packages/studio-server/src/preview-server/start-server.ts
+++ b/packages/studio-server/src/preview-server/start-server.ts
@@ -101,7 +101,11 @@ export const startServer = async (options: {
});
})
.catch((err) => {
- RenderInternals.Log.error(`Error while calling ${request.url}`, err);
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel: options.logLevel},
+ `Error while calling ${request.url}`,
+ err,
+ );
if (!response.headersSent) {
response.setHeader('content-type', 'application/json');
response.writeHead(500);
@@ -159,7 +163,8 @@ export const startServer = async (options: {
const codedError = err as Error & {code: string; port: number};
if (codedError.code === 'EADDRINUSE') {
- RenderInternals.Log.error(
+ RenderInternals.Log.errorAdvanced(
+ {indent: false, logLevel: options.logLevel},
`Port ${codedError.port} is already in use. Trying another port...`,
);
} else {
diff --git a/packages/studio-server/src/routes.ts b/packages/studio-server/src/routes.ts
index d0a7d68f7c..924975dd26 100644
--- a/packages/studio-server/src/routes.ts
+++ b/packages/studio-server/src/routes.ts
@@ -149,6 +149,7 @@ const handleOpenInEditor = async (
remotionRoot: string,
req: IncomingMessage,
res: ServerResponse,
+ logLevel: LogLevel,
) => {
if (req.method === 'OPTIONS') {
res.statusCode = 200;
@@ -173,6 +174,7 @@ const handleOpenInEditor = async (
fileName: path.resolve(remotionRoot, stack.originalFileName as string),
lineNumber: stack.originalLineNumber as number,
vsCodeNewWindow: false,
+ logLevel,
});
res.setHeader('content-type', 'application/json');
res.writeHead(200);
@@ -293,7 +295,7 @@ export const handleRoutes = ({
}
if (url.pathname === '/api/open-in-editor') {
- return handleOpenInEditor(remotionRoot, request, response);
+ return handleOpenInEditor(remotionRoot, request, response, logLevel);
}
for (const [key, value] of Object.entries(allApiRoutes)) {