Skip to content

🎥 Make videos programmatically with React

log level

Jonny Burger6efc92613ec5
diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.ts
index a564c2afe7..0034fd1ccc 100644
--- a/packages/cli/src/benchmark.ts
+++ b/packages/cli/src/benchmark.ts
@@ -247,7 +247,7 @@ export const benchmarkCommand = async (
remotionRoot,
onProgress: () => undefined,
indentOutput: false,
- logLevel: ConfigInternals.Logging.getLogLevel(),
+ logLevel,
bundlingStep: 0,
steps: 1,
onDirectoryCreated: (dir) => {
diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts
index e6a58e4f8f..5d911bcf77 100644
--- a/packages/cli/src/config/index.ts
+++ b/packages/cli/src/config/index.ts
@@ -15,7 +15,6 @@ import {
setVideoImageFormat,
} from './image-format';
import {getShouldOutputImageSequence} from './image-sequence';
-import * as Logging from './log';
import {getOutputLocation} from './output-location';
import {
defaultOverrideFunction,
@@ -74,7 +73,6 @@ import {
getKeyboardShortcutsEnabled,
setKeyboardShortcutsEnabled,
} from './keyboard-shortcuts';
-import {setLogLevel} from './log';
import {setNumberOfSharedAudioTags} from './number-of-shared-audio-tags';
import {getShouldOpenBrowser, setShouldOpenBrowser} from './open-browser';
import {setOutputLocation} from './output-location';
@@ -118,6 +116,7 @@ const {
encodingBufferSizeOption,
reproOption,
enableLambdaInsights,
+ logLevelOption,
} = BrowserSafeApis.options;
declare global {
@@ -551,7 +550,7 @@ export const Config: FlatConfig = {
setRendererPort,
setPublicDir,
setEntryPoint,
- setLevel: setLogLevel,
+ setLevel: logLevelOption.setConfig,
setBrowserExecutable,
setTimeoutInMilliseconds: setPuppeteerTimeout,
setDelayRenderTimeoutInMilliseconds: setPuppeteerTimeout,
@@ -634,7 +633,6 @@ export const ConfigInternals = {
getWebpackOverrideFn,
getWebpackCaching,
getOutputLocation,
- Logging,
setFrameRangeFromCli,
setStillFrame,
getMaxTimelineTracks: StudioServerInternals.getMaxTimelineTracks,
diff --git a/packages/cli/src/config/log.ts b/packages/cli/src/config/log.ts
deleted file mode 100644
index c325c1723c..0000000000
--- a/packages/cli/src/config/log.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import {RenderInternals} from '@remotion/renderer';
-
-export const {getLogLevel, setLogLevel} = RenderInternals;
diff --git a/packages/cli/src/ffmpeg.ts b/packages/cli/src/ffmpeg.ts
index 1e67f2aed5..6344166418 100644
--- a/packages/cli/src/ffmpeg.ts
+++ b/packages/cli/src/ffmpeg.ts
@@ -3,7 +3,6 @@ import {RenderInternals} from '@remotion/renderer';
import {spawnSync} from 'node:child_process';
import {chmodSync} from 'node:fs';
import path from 'node:path';
-import {ConfigInternals} from './config';
export const dynamicLibEnv = (indent: boolean, logLevel: LogLevel) => {
const lib = path.dirname(
@@ -26,9 +25,11 @@ export const dynamicLibEnv = (indent: boolean, logLevel: LogLevel) => {
};
};
-export const ffmpegCommand = (_root: string, args: string[]) => {
- const logLevel = ConfigInternals.Logging.getLogLevel();
-
+export const ffmpegCommand = (
+ _root: string,
+ args: string[],
+ logLevel: LogLevel,
+) => {
const binary = RenderInternals.getExecutablePath('ffmpeg', false, logLevel);
if (!process.env.READ_ONLY_FS) {
chmodSync(binary, 0o755);
@@ -41,9 +42,11 @@ export const ffmpegCommand = (_root: string, args: string[]) => {
process.exit(done.status as number);
};
-export const ffprobeCommand = (_root: string, args: string[]) => {
- const logLevel = ConfigInternals.Logging.getLogLevel();
-
+export const ffprobeCommand = (
+ _root: string,
+ args: string[],
+ logLevel: LogLevel,
+) => {
const binary = RenderInternals.getExecutablePath('ffprobe', false, logLevel);
if (!process.env.READ_ONLY_FS) {
chmodSync(binary, 0o755);
diff --git a/packages/cli/src/get-cli-options.ts b/packages/cli/src/get-cli-options.ts
index ba14903e1d..62f00dd856 100644
--- a/packages/cli/src/get-cli-options.ts
+++ b/packages/cli/src/get-cli-options.ts
@@ -114,7 +114,6 @@ export const getCliOptions = (options: {
everyNthFrame,
stillFrame: ConfigInternals.getStillFrame(),
browserExecutable,
- logLevel: ConfigInternals.Logging.getLogLevel(),
userAgent,
headless,
disableWebSecurity,
diff --git a/packages/cli/src/get-render-defaults.ts b/packages/cli/src/get-render-defaults.ts
index 63e53bdb96..1da6ecce9a 100644
--- a/packages/cli/src/get-render-defaults.ts
+++ b/packages/cli/src/get-render-defaults.ts
@@ -21,13 +21,14 @@ const {
encodingMaxRateOption,
encodingBufferSizeOption,
reproOption,
+ logLevelOption,
} = BrowserSafeApis.options;
export const getRenderDefaults = (): RenderDefaults => {
const defaultJpegQuality = jpegQualityOption.getValue({
commandLine: parsedCli,
}).value;
- const logLevel = ConfigInternals.Logging.getLogLevel();
+ const logLevel = logLevelOption.getValue({commandLine: parsedCli}).value;
const defaultCodec = ConfigInternals.getOutputCodecOrUndefined();
const concurrency = RenderInternals.getActualConcurrency(
ConfigInternals.getConcurrency(),
diff --git a/packages/cli/src/index.tsx b/packages/cli/src/index.tsx
index 23675dcd6e..3a0bb90777 100644
--- a/packages/cli/src/index.tsx
+++ b/packages/cli/src/index.tsx
@@ -6,7 +6,6 @@ import {chalk} from './chalk';
import {cleanupBeforeQuit, handleCtrlC} from './cleanup-before-quit';
import {cloudrunCommand} from './cloudrun-command';
import {listCompositionsCommand} from './compositions';
-import {ConfigInternals} from './config';
import {determineFinalStillImageFormat} from './determine-image-format';
import {getFileSizeDownloadBar} from './download-progress';
import {findEntryPoint} from './entry-point';
@@ -92,11 +91,11 @@ export const cli = async () => {
} else if (command === 'still') {
await still(remotionRoot, args, logLevel);
} else if (command === 'ffmpeg') {
- ffmpegCommand(remotionRoot, process.argv.slice(3));
+ ffmpegCommand(remotionRoot, process.argv.slice(3), logLevel);
} else if (command === 'gpu') {
await gpuCommand(remotionRoot, logLevel);
} else if (command === 'ffprobe') {
- ffprobeCommand(remotionRoot, process.argv.slice(3));
+ ffprobeCommand(remotionRoot, process.argv.slice(3), logLevel);
} else if (command === 'upgrade') {
await upgrade(
remotionRoot,
@@ -120,7 +119,7 @@ export const cli = async () => {
}
} catch (err) {
Log.info();
- await printError(err as Error, ConfigInternals.Logging.getLogLevel());
+ await printError(err as Error, logLevel);
cleanupBeforeQuit({indent: false, logLevel});
process.exit(1);
} finally {
diff --git a/packages/cli/src/initialize-cli.ts b/packages/cli/src/initialize-cli.ts
index d5541b66cc..13a642ecdc 100644
--- a/packages/cli/src/initialize-cli.ts
+++ b/packages/cli/src/initialize-cli.ts
@@ -1,8 +1,8 @@
import type {LogLevel} from '@remotion/renderer';
-import {ConfigInternals} from './config';
+import {BrowserSafeApis} from '@remotion/renderer/client';
import {loadConfig} from './get-config-file-name';
import {Log} from './log';
-import {parseCommandLine} from './parse-command-line';
+import {parseCommandLine, parsedCli} from './parse-command-line';
export const initializeCli = async (
remotionRoot: string,
@@ -10,7 +10,9 @@ export const initializeCli = async (
const appliedName = await loadConfig(remotionRoot);
parseCommandLine();
- const logLevel = ConfigInternals.Logging.getLogLevel();
+ const logLevel = BrowserSafeApis.options.logLevelOption.getValue({
+ commandLine: parsedCli,
+ }).value;
// Only now Log.verbose is available
Log.verbose(
{indent: false, logLevel},
diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.ts
index 425ade8929..9a4abe9c9c 100644
--- a/packages/cli/src/parse-command-line.ts
+++ b/packages/cli/src/parse-command-line.ts
@@ -182,7 +182,7 @@ export const parseCommandLine = () => {
process.exit(1);
}
- ConfigInternals.Logging.setLogLevel(parsedCli.log as LogLevel);
+ BrowserSafeApis.options.logLevelOption.setConfig(parsedCli.log as LogLevel);
}
if (parsedCli.concurrency) {
diff --git a/packages/cli/src/render-queue/queue.ts b/packages/cli/src/render-queue/queue.ts
index 9f502cab39..5b95e31eaf 100644
--- a/packages/cli/src/render-queue/queue.ts
+++ b/packages/cli/src/render-queue/queue.ts
@@ -8,7 +8,6 @@ import type {
import {StudioServerInternals} from '@remotion/studio-server';
import path from 'node:path';
import {chalk} from '../chalk';
-import {ConfigInternals} from '../config';
import {Log} from '../log';
import {printError} from '../print-error';
import {initialAggregateRenderProgress} from '../progress-types';
@@ -263,7 +262,7 @@ const processJobIfPossible = async ({
};
});
- await printError(err as Error, ConfigInternals.Logging.getLogLevel());
+ await printError(err as Error, logLevel);
StudioServerInternals.waitForLiveEventsListener().then((listener) => {
listener.sendEventToClient({
diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsx
index 0f4ae2863b..446adb3e2d 100644
--- a/packages/cli/src/render.tsx
+++ b/packages/cli/src/render.tsx
@@ -3,7 +3,6 @@ import type {ChromiumOptions, LogLevel} from '@remotion/renderer';
import {BrowserSafeApis} from '@remotion/renderer/client';
import {NoReactInternals} from 'remotion/no-react';
import {registerCleanupJob} from './cleanup-before-quit';
-import {ConfigInternals} from './config';
import {getRendererPortFromConfigFileAndCliFlag} from './config/preview-server';
import {convertEntryPointToServeUrl} from './convert-entry-point-to-serve-url';
import {findEntryPoint} from './entry-point';
@@ -145,7 +144,7 @@ export const render = async (
remotionRoot,
browserExecutable,
indent: false,
- logLevel: ConfigInternals.Logging.getLogLevel(),
+ logLevel,
browser: 'chrome',
chromiumOptions,
scale,
diff --git a/packages/cli/src/test/log.test.ts b/packages/cli/src/test/log.test.ts
index db14c3038e..013885423e 100644
--- a/packages/cli/src/test/log.test.ts
+++ b/packages/cli/src/test/log.test.ts
@@ -1,16 +1,22 @@
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
+import {BrowserSafeApis} from '@remotion/renderer/client';
import {describe, expect, test} from 'vitest';
-import {getLogLevel, setLogLevel} from '../config/log';
+
+const {logLevelOption} = BrowserSafeApis.options;
+
describe('test loglevel getter and setter', () => {
test('default log level', () => {
- expect(getLogLevel()).toEqual('info');
+ expect(logLevelOption.getValue({commandLine: {}}).value).toEqual('info');
});
test.each<LogLevel>(['verbose', 'warn', 'error', 'info'])(
'test for %s',
(loglevel) => {
- setLogLevel(loglevel);
- expect(getLogLevel()).toEqual(loglevel);
+ logLevelOption.setConfig(loglevel);
+
+ expect(logLevelOption.getValue({commandLine: {}}).value).toEqual(
+ loglevel,
+ );
},
);
});
@@ -28,9 +34,12 @@ describe('loglevel comparison', () => {
['warn', 'error'],
['error', 'error'],
])('%s is equal or below %s', (level1, level2) => {
- setLogLevel(level1);
+ logLevelOption.setConfig(level1);
expect(
- RenderInternals.isEqualOrBelowLogLevel(getLogLevel(), level2),
+ RenderInternals.isEqualOrBelowLogLevel(
+ logLevelOption.getValue({commandLine: {}}).value,
+ level2,
+ ),
).toEqual(true);
});
@@ -42,9 +51,12 @@ describe('loglevel comparison', () => {
['error', 'info'],
['error', 'warn'],
])('%s is not equal or below %s', (level1, level2) => {
- setLogLevel(level1);
+ logLevelOption.setConfig(level1);
expect(
- RenderInternals.isEqualOrBelowLogLevel(getLogLevel(), level2),
+ RenderInternals.isEqualOrBelowLogLevel(
+ logLevelOption.getValue({commandLine: {}}).value,
+ level2,
+ ),
).toEqual(false);
});
});
diff --git a/packages/cli/src/upgrade.ts b/packages/cli/src/upgrade.ts
index 5b9cc889f6..b67b0e077c 100644
--- a/packages/cli/src/upgrade.ts
+++ b/packages/cli/src/upgrade.ts
@@ -1,10 +1,11 @@
import {RenderInternals} from '@remotion/renderer';
+import {BrowserSafeApis} from '@remotion/renderer/client';
import type {PackageManager} from '@remotion/studio-server';
import {StudioServerInternals} from '@remotion/studio-server';
import path from 'node:path';
-import {ConfigInternals} from './config';
import {listOfRemotionPackages} from './list-of-remotion-packages';
import {Log} from './log';
+import {parsedCli} from './parse-command-line';
const getUpgradeCommand = ({
manager,
@@ -84,7 +85,8 @@ export const upgrade = async (
);
if (
RenderInternals.isEqualOrBelowLogLevel(
- ConfigInternals.Logging.getLogLevel(),
+ BrowserSafeApis.options.logLevelOption.getValue({commandLine: parsedCli})
+ .value,
'info',
)
) {
diff --git a/packages/cli/src/versions.ts b/packages/cli/src/versions.ts
index 97d0c5eb6e..57e2ffc6f9 100644
--- a/packages/cli/src/versions.ts
+++ b/packages/cli/src/versions.ts
@@ -1,7 +1,6 @@
import type {LogLevel, LogOptions} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import fs from 'node:fs';
-import {ConfigInternals} from './config';
import {listOfRemotionPackages} from './list-of-remotion-packages';
import {Log} from './log';
import {parseCommandLine} from './parse-command-line';
@@ -94,12 +93,7 @@ export const validateVersionsBeforeCommand = async (
logOptions,
'- Remove the `^` character in front of a version to pin a package.',
);
- if (
- !RenderInternals.isEqualOrBelowLogLevel(
- ConfigInternals.Logging.getLogLevel(),
- 'verbose',
- )
- ) {
+ if (!RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose')) {
Log.warn(
logOptions,
'- Run `npx remotion versions --log=verbose` to see the path of the modules resolved.',
@@ -158,12 +152,7 @@ export const versionsCommand = async (
Log.info(
'- Remove the `^` character in front of a version to pin a package.',
);
- if (
- !RenderInternals.isEqualOrBelowLogLevel(
- ConfigInternals.Logging.getLogLevel(),
- 'verbose',
- )
- ) {
+ if (!RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose')) {
Log.info(
'- Rerun this command with --log=verbose to see the path of the modules resolved.',
);
diff --git a/packages/cloudrun/src/cli/commands/render/index.ts b/packages/cloudrun/src/cli/commands/render/index.ts
index 0b5e8cf83b..d29dc8e88a 100644
--- a/packages/cloudrun/src/cli/commands/render/index.ts
+++ b/packages/cloudrun/src/cli/commands/render/index.ts
@@ -283,7 +283,7 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}
muted,
forceWidth: width,
forceHeight: height,
- logLevel: ConfigInternals.Logging.getLogLevel(),
+ logLevel,
delayRenderTimeoutInMilliseconds: puppeteerTimeout,
// Special case: Should not use default local concurrency, or from
// config file, just when explicitly set
diff --git a/packages/cloudrun/src/cli/commands/still.ts b/packages/cloudrun/src/cli/commands/still.ts
index c20a5a7e12..8b911e0a95 100644
--- a/packages/cloudrun/src/cli/commands/still.ts
+++ b/packages/cloudrun/src/cli/commands/still.ts
@@ -200,7 +200,7 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}
forceWidth: width,
forceBucketName,
outName,
- logLevel: ConfigInternals.Logging.getLogLevel(),
+ logLevel,
delayRenderTimeoutInMilliseconds: puppeteerTimeout,
});
if (res.type === 'crash') {
diff --git a/packages/cloudrun/src/cli/index.ts b/packages/cloudrun/src/cli/index.ts
index 0a04e645ed..a2415956b7 100644
--- a/packages/cloudrun/src/cli/index.ts
+++ b/packages/cloudrun/src/cli/index.ts
@@ -1,5 +1,4 @@
import {CliInternals} from '@remotion/cli';
-import {ConfigInternals} from '@remotion/cli/config';
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import {parsedCloudrunCli} from './args';
@@ -67,10 +66,7 @@ export const executeCommand = async (
} catch (err) {
const error = err as Error;
if (error instanceof RenderInternals.SymbolicateableError) {
- await CliInternals.printError(
- error,
- ConfigInternals.Logging.getLogLevel(),
- );
+ await CliInternals.printError(error, logLevel);
} else {
const frames = RenderInternals.parseStack(error.stack?.split('\n') ?? []);
@@ -81,10 +77,7 @@ export const executeCommand = async (
stack: error.stack,
stackFrame: frames,
});
- await CliInternals.printError(
- errorWithStackFrame,
- ConfigInternals.Logging.getLogLevel(),
- );
+ await CliInternals.printError(errorWithStackFrame, logLevel);
}
quit(1);
diff --git a/packages/cloudrun/src/functions/index.ts b/packages/cloudrun/src/functions/index.ts
index cea6fd1b2b..393973bc81 100644
--- a/packages/cloudrun/src/functions/index.ts
+++ b/packages/cloudrun/src/functions/index.ts
@@ -1,5 +1,5 @@
import type * as ff from '@google-cloud/functions-framework';
-import {RenderInternals} from '@remotion/renderer';
+import {BrowserSafeApis} from '@remotion/renderer/client';
import type {ErrorResponsePayload} from './helpers/payloads';
import {CloudRunPayload} from './helpers/payloads';
import {renderMediaSingleThread} from './render-media-single-thread';
@@ -10,7 +10,7 @@ const renderOnCloudRun = async (req: ff.Request, res: ff.Response) => {
const body = CloudRunPayload.parse(req.body);
const renderType = body.type;
- RenderInternals.setLogLevel(body.logLevel);
+ BrowserSafeApis.options.logLevelOption.setConfig(body.logLevel);
switch (renderType) {
case 'media':
await renderMediaSingleThread(body, res);
diff --git a/packages/docs/docs/renderer/render-still.md b/packages/docs/docs/renderer/render-still.md
index 0bdf41dc08..9ac0d3568c 100644
--- a/packages/docs/docs/renderer/render-still.md
+++ b/packages/docs/docs/renderer/render-still.md
@@ -120,7 +120,7 @@ _optional - default `{}`_
An object containing key-value pairs of environment variables which will be injected into your Remotion project and which can be accessed by reading the global `process.env` object.
-### `logLevel?`<AvailableFrom v="4.0.0"/>
+### `logLevel?`<AvailableFrom v="4.0.115"/>
One of `verbose`, `info`, `warn`, `error`. Determines how much is being logged to the console.
`verbose` will also log `console.log`'s from the browser.
diff --git a/packages/lambda/src/cli/commands/functions/index.ts b/packages/lambda/src/cli/commands/functions/index.ts
index 0543c905d7..09e9ac84fe 100644
--- a/packages/lambda/src/cli/commands/functions/index.ts
+++ b/packages/lambda/src/cli/commands/functions/index.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 {functionsDeploySubcommand, FUNCTIONS_DEPLOY_SUBCOMMAND} from './deploy';
@@ -40,17 +41,17 @@ const printFunctionsHelp = () => {
);
};
-export const functionsCommand = (args: string[]) => {
+export const functionsCommand = (args: string[], logLevel: LogLevel) => {
if (args[0] === FUNCTIONS_LS_SUBCOMMAND) {
- return functionsLsCommand();
+ return functionsLsCommand(logLevel);
}
if (args[0] === FUNCTIONS_RM_SUBCOMMAND) {
- return functionsRmCommand(args.slice(1));
+ return functionsRmCommand(args.slice(1), logLevel);
}
if (args[0] === FUNCTIONS_RMALL_SUBCOMMAND) {
- return functionsRmallCommand();
+ return functionsRmallCommand(logLevel);
}
if (args[0] === FUNCTIONS_DEPLOY_SUBCOMMAND) {
diff --git a/packages/lambda/src/cli/commands/functions/ls.ts b/packages/lambda/src/cli/commands/functions/ls.ts
index 1c9c2b623a..7569c3a890 100644
--- a/packages/lambda/src/cli/commands/functions/ls.ts
+++ b/packages/lambda/src/cli/commands/functions/ls.ts
@@ -1,5 +1,5 @@
import {CliInternals} from '@remotion/cli';
-import {RenderInternals} from '@remotion/renderer';
+import type {LogLevel} from '@remotion/renderer';
import {getFunctions} from '../../../api/get-functions';
import {getAwsRegion} from '../../get-aws-region';
@@ -11,13 +11,13 @@ const VERSION_COLS = 15;
export const FUNCTIONS_LS_SUBCOMMAND = 'ls';
-export const functionsLsCommand = async () => {
+export const functionsLsCommand = async (logLevel: LogLevel) => {
const region = getAwsRegion();
const fetchingOutput = CliInternals.createOverwriteableCliOutput({
quiet: CliInternals.quietFlagProvided(),
cancelSignal: null,
updatesDontOverwrite: CliInternals.shouldUseNonOverlayingLogger({
- logLevel: RenderInternals.getLogLevel(),
+ logLevel,
}),
indent: false,
});
diff --git a/packages/lambda/src/cli/commands/functions/rm.ts b/packages/lambda/src/cli/commands/functions/rm.ts
index 851a78aed3..22c0662a55 100644
--- a/packages/lambda/src/cli/commands/functions/rm.ts
+++ b/packages/lambda/src/cli/commands/functions/rm.ts
@@ -1,5 +1,5 @@
import {CliInternals} from '@remotion/cli';
-import {RenderInternals} from '@remotion/renderer';
+import type {LogLevel} from '@remotion/renderer';
import {deleteFunction} from '../../../api/delete-function';
import {getFunctionInfo} from '../../../api/get-function-info';
import {BINARY_NAME} from '../../../shared/constants';
@@ -13,7 +13,10 @@ import {FUNCTIONS_LS_SUBCOMMAND} from './ls';
export const FUNCTIONS_RM_SUBCOMMAND = 'rm';
const LEFT_COL = 16;
-export const functionsRmCommand = async (args: string[]) => {
+export const functionsRmCommand = async (
+ args: string[],
+ logLevel: LogLevel,
+) => {
if (args.length === 0) {
Log.error('No function name passed.');
Log.error(
@@ -66,7 +69,7 @@ export const functionsRmCommand = async (args: string[]) => {
quiet: CliInternals.quietFlagProvided(),
cancelSignal: null,
updatesDontOverwrite: CliInternals.shouldUseNonOverlayingLogger({
- logLevel: RenderInternals.getLogLevel(),
+ logLevel,
}),
indent: false,
});
diff --git a/packages/lambda/src/cli/commands/functions/rmall.ts b/packages/lambda/src/cli/commands/functions/rmall.ts
index 95ee039922..65b490e4a5 100644
--- a/packages/lambda/src/cli/commands/functions/rmall.ts
+++ b/packages/lambda/src/cli/commands/functions/rmall.ts
@@ -1,5 +1,5 @@
import {CliInternals} from '@remotion/cli';
-import {RenderInternals} from '@remotion/renderer';
+import type {LogLevel} from '@remotion/renderer';
import {deleteFunction} from '../../../api/delete-function';
import {getFunctionInfo} from '../../../api/get-function-info';
import {getFunctions} from '../../../api/get-functions';
@@ -9,7 +9,7 @@ import {confirmCli} from '../../helpers/confirm';
export const FUNCTIONS_RMALL_SUBCOMMAND = 'rmall';
const LEFT_COL = 16;
-export const functionsRmallCommand = async () => {
+export const functionsRmallCommand = async (logLevel: LogLevel) => {
const region = getAwsRegion();
const functions = await getFunctions({
region,
@@ -50,7 +50,7 @@ export const functionsRmallCommand = async () => {
quiet: CliInternals.quietFlagProvided(),
cancelSignal: null,
updatesDontOverwrite: CliInternals.shouldUseNonOverlayingLogger({
- logLevel: RenderInternals.getLogLevel(),
+ logLevel,
}),
indent: false,
});
diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.ts
index 86432d8623..bf67a44a19 100644
--- a/packages/lambda/src/cli/index.ts
+++ b/packages/lambda/src/cli/index.ts
@@ -1,5 +1,4 @@
import {CliInternals} from '@remotion/cli';
-import {ConfigInternals} from '@remotion/cli/config';
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import {ROLE_NAME} from '../api/iam-validation/suggested-policy';
@@ -70,7 +69,7 @@ const matchCommand = (
}
if (args[0] === FUNCTIONS_COMMAND) {
- return functionsCommand(args.slice(1));
+ return functionsCommand(args.slice(1), logLevel);
}
if (args[0] === QUOTAS_COMMAND) {
@@ -204,10 +203,7 @@ AWS returned an error message "The security token included in the request is inv
}
if (error instanceof RenderInternals.SymbolicateableError) {
- await CliInternals.printError(
- error,
- ConfigInternals.Logging.getLogLevel(),
- );
+ await CliInternals.printError(error, logLevel);
} else {
const frames = RenderInternals.parseStack(error.stack?.split('\n') ?? []);
@@ -218,10 +214,7 @@ AWS returned an error message "The security token included in the request is inv
stack: error.stack,
stackFrame: frames,
});
- await CliInternals.printError(
- errorWithStackFrame,
- ConfigInternals.Logging.getLogLevel(),
- );
+ await CliInternals.printError(errorWithStackFrame, logLevel);
}
quit(1);
diff --git a/packages/lambda/src/functions/index.ts b/packages/lambda/src/functions/index.ts
index 16ee278c67..2ca3d723e6 100644
--- a/packages/lambda/src/functions/index.ts
+++ b/packages/lambda/src/functions/index.ts
@@ -1,4 +1,5 @@
import {RenderInternals} from '@remotion/renderer';
+import {BrowserSafeApis} from '@remotion/renderer/client';
import type {LambdaPayload} from '../shared/constants';
import {COMMAND_NOT_FOUND, LambdaRoutines} from '../shared/constants';
import type {OrError} from '../shared/return-values';
@@ -54,7 +55,7 @@ const innerHandler = async (
inputProps: JSON.stringify(params.inputProps),
isWarm,
});
- RenderInternals.setLogLevel(params.logLevel);
+ BrowserSafeApis.options.logLevelOption.setConfig(params.logLevel);
const renderIdDetermined: StreamingPayloads = {
type: 'render-id-determined',
@@ -79,7 +80,7 @@ const innerHandler = async (
inputProps: JSON.stringify(params.inputProps),
isWarm,
});
- RenderInternals.setLogLevel(params.logLevel);
+ BrowserSafeApis.options.logLevelOption.setConfig(params.logLevel);
const response = await startHandler(params, {
expectedBucketOwner: currentUserId,
@@ -96,7 +97,7 @@ const innerHandler = async (
inputProps: JSON.stringify(params.inputProps),
isWarm,
});
- RenderInternals.setLogLevel(params.logLevel);
+ BrowserSafeApis.options.logLevelOption.setConfig(params.logLevel);
const response = await launchHandler(params, {
expectedBucketOwner: currentUserId,
@@ -134,7 +135,7 @@ const innerHandler = async (
resolvedProps: JSON.stringify(params.resolvedProps),
isWarm,
});
- RenderInternals.setLogLevel(params.logLevel);
+ BrowserSafeApis.options.logLevelOption.setConfig(params.logLevel);
const response = await rendererHandler(
params,
@@ -169,7 +170,7 @@ const innerHandler = async (
isWarm,
});
- RenderInternals.setLogLevel(params.logLevel);
+ BrowserSafeApis.options.logLevelOption.setConfig(params.logLevel);
const response = await mergeHandler(params, {
expectedBucketOwner: currentUserId,
diff --git a/packages/renderer/src/get-compositions.ts b/packages/renderer/src/get-compositions.ts
index 026cc4a252..8279f4c8da 100644
--- a/packages/renderer/src/get-compositions.ts
+++ b/packages/renderer/src/get-compositions.ts
@@ -9,7 +9,6 @@ import {handleJavascriptException} from './error-handling/handle-javascript-exce
import {findRemotionRoot} from './find-closest-package-json';
import {getPageAndCleanupFn} from './get-browser-instance';
import {type LogLevel} from './log-level';
-import {getLogLevel} from './logger';
import type {ChromiumOptions} from './open-browser';
import type {ToOptions} from './options/option';
import type {optionsMap} from './options/options-map';
@@ -287,7 +286,7 @@ export const getCompositions = (
serveUrlOrWebpackUrl,
server: undefined,
timeoutInMilliseconds: timeoutInMilliseconds ?? DEFAULT_TIMEOUT,
- logLevel: logLevel ?? getLogLevel(),
+ logLevel: logLevel ?? 'info',
offthreadVideoCacheSizeInBytes:
config?.offthreadVideoCacheSizeInBytes ?? null,
});
diff --git a/packages/renderer/src/index.ts b/packages/renderer/src/index.ts
index 9484650396..2b737c5950 100644
--- a/packages/renderer/src/index.ts
+++ b/packages/renderer/src/index.ts
@@ -48,7 +48,7 @@ import {isAudioCodec} from './is-audio-codec';
import {isServeUrl} from './is-serve-url';
import {DEFAULT_JPEG_QUALITY, validateJpegQuality} from './jpeg-quality';
import {isEqualOrBelowLogLevel, isValidLogLevel, logLevels} from './log-level';
-import {getLogLevel, INDENT_TOKEN, Log, setLogLevel} from './logger';
+import {INDENT_TOKEN, Log} from './logger';
import {mimeContentType, mimeLookup} from './mime-types';
import {internalOpenBrowser, killAllBrowsers} from './open-browser';
import {
@@ -205,8 +205,6 @@ export const RenderInternals = {
DEFAULT_JPEG_QUALITY,
chalk,
Log,
- getLogLevel,
- setLogLevel,
INDENT_TOKEN,
isColorSupported,
HeadlessBrowser,
diff --git a/packages/renderer/src/logger.ts b/packages/renderer/src/logger.ts
index 8a62ef5ab9..a9b1928284 100644
--- a/packages/renderer/src/logger.ts
+++ b/packages/renderer/src/logger.ts
@@ -2,6 +2,7 @@ import {chalk} from './chalk';
import {isColorSupported} from './chalk/is-color-supported';
import type {LogLevel} from './log-level';
import {isEqualOrBelowLogLevel} from './log-level';
+import {logLevelOption} from './options/log-level';
import {writeInRepro} from './repro';
import {truthy} from './truthy';
@@ -42,7 +43,13 @@ export const Log = {
}
},
info: (...args: Parameters<typeof console.log>) => {
- Log.infoAdvanced({indent: false, logLevel: getLogLevel()}, ...args);
+ Log.infoAdvanced(
+ {
+ indent: false,
+ logLevel: logLevelOption.getValue({commandLine: {}}).value,
+ },
+ ...args,
+ );
},
infoAdvanced: (
options: LogOptions,
@@ -66,7 +73,12 @@ export const Log = {
},
error: (...args: Parameters<typeof console.log>) => {
writeInRepro('error', ...args);
- if (isEqualOrBelowLogLevel(getLogLevel(), 'error')) {
+ if (
+ isEqualOrBelowLogLevel(
+ logLevelOption.getValue({commandLine: {}}).value,
+ 'error',
+ )
+ ) {
return console.error(...args.map((a) => chalk.red(a)));
}
},
@@ -75,7 +87,7 @@ export const Log = {
...args: Parameters<typeof console.log>
) => {
writeInRepro('error', ...args);
- if (isEqualOrBelowLogLevel(getLogLevel(), 'error')) {
+ if (isEqualOrBelowLogLevel(options.logLevel, 'error')) {
return console.log(
...[
options.indent ? INDENT_TOKEN : null,
@@ -87,13 +99,3 @@ export const Log = {
}
},
};
-
-let logLevel: LogLevel = 'info';
-
-export const getLogLevel = () => {
- return logLevel;
-};
-
-export const setLogLevel = (newLogLevel: LogLevel) => {
- logLevel = newLogLevel;
-};
diff --git a/packages/renderer/src/options/index.tsx b/packages/renderer/src/options/index.tsx
index 77fe8707f5..611ea9656d 100644
--- a/packages/renderer/src/options/index.tsx
+++ b/packages/renderer/src/options/index.tsx
@@ -11,6 +11,7 @@ import {enforceAudioOption} from './enforce-audio';
import {folderExpiryOption} from './folder-expiry';
import {glOption} from './gl';
import {jpegQualityOption} from './jpeg-quality';
+import {logLevelOption} from './log-level';
import {mutedOption} from './mute';
import {numberOfGifLoopsOption} from './number-of-gif-loops';
import {offthreadVideoCacheSizeInBytesOption} from './offthreadvideo-cache-size';
@@ -45,6 +46,7 @@ export const allOptions = {
numberOfGifLoopsOption,
reproOption,
x264Option,
+ logLevelOption,
};
export type AvailableOptions = keyof typeof allOptions;
diff --git a/packages/renderer/src/options/log-level.tsx b/packages/renderer/src/options/log-level.tsx
new file mode 100644
index 0000000000..f8d3115849
--- /dev/null
+++ b/packages/renderer/src/options/log-level.tsx
@@ -0,0 +1,36 @@
+import type {LogLevel} from '../log-level';
+import type {AnyRemotionOption} from './option';
+
+let logLevel: LogLevel = 'info';
+
+const cliFlag = 'log-level' as const;
+
+export const logLevelOption = {
+ cliFlag,
+ name: 'Log Level',
+ ssrName: 'logLevel',
+ description: () => (
+ <>
+ One of <code>verbose</code>, <code>info</code>, <code>warn</code>,
+ <code>error</code>. Determines how much is being logged to the console.{' '}
+ <code>verbose</code> will also log <code>console.log</code>
+ {"'"}s from the browser. Default <code>info</code>
+ </>
+ ),
+ docLink: 'https://www.remotion.dev/docs/troubleshooting/debug-failed-render',
+ getValue: ({commandLine}) => {
+ if (commandLine[cliFlag]) {
+ return {value: commandLine[cliFlag] as LogLevel, source: 'cli'};
+ }
+
+ if (logLevel !== 'info') {
+ return {value: logLevel, source: 'config'};
+ }
+
+ return {value: 'info', source: 'default'};
+ },
+ setConfig: (newLogLevel: LogLevel) => {
+ logLevel = newLogLevel;
+ },
+ type: 'error' as LogLevel,
+} satisfies AnyRemotionOption<LogLevel>;
diff --git a/packages/renderer/src/render-frames.ts b/packages/renderer/src/render-frames.ts
index 57c5467609..a28148c2b3 100644
--- a/packages/renderer/src/render-frames.ts
+++ b/packages/renderer/src/render-frames.ts
@@ -33,7 +33,7 @@ import {getRealFrameRange} from './get-frame-to-render';
import type {VideoImageFormat} from './image-format';
import {DEFAULT_JPEG_QUALITY, validateJpegQuality} from './jpeg-quality';
import {type LogLevel} from './log-level';
-import {getLogLevel, Log} from './logger';
+import {Log} from './logger';
import type {CancelSignal} from './make-cancel-signal';
import {cancelErrorMessages, isUserCancelledRender} from './make-cancel-signal';
import type {ChromiumOptions} from './open-browser';
@@ -882,8 +882,7 @@ export const renderFrames = (
outputDir,
port: port ?? null,
scale: scale ?? 1,
- logLevel:
- verbose || dumpBrowserLogs ? 'verbose' : logLevel ?? getLogLevel(),
+ logLevel: verbose || dumpBrowserLogs ? 'verbose' : logLevel ?? 'info',
timeoutInMilliseconds: timeoutInMilliseconds ?? DEFAULT_TIMEOUT,
webpackBundleOrServeUrl: serveUrl,
server: undefined,
diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.ts
index 537c893946..d28fe81b2d 100644
--- a/packages/renderer/src/render-media.ts
+++ b/packages/renderer/src/render-media.ts
@@ -33,7 +33,7 @@ import {
import {isAudioCodec} from './is-audio-codec';
import {DEFAULT_JPEG_QUALITY, validateJpegQuality} from './jpeg-quality';
import {type LogLevel} from './log-level';
-import {getLogLevel, Log} from './logger';
+import {Log} from './logger';
import type {CancelSignal} from './make-cancel-signal';
import {cancelErrorMessages, makeCancelSignal} from './make-cancel-signal';
import type {ChromiumOptions} from './open-browser';
@@ -884,8 +884,7 @@ export const renderMedia = ({
videoBitrate: videoBitrate ?? null,
encodingMaxRate: encodingMaxRate ?? null,
encodingBufferSize: encodingBufferSize ?? null,
- logLevel:
- verbose || dumpBrowserLogs ? 'verbose' : logLevel ?? getLogLevel(),
+ logLevel: verbose || dumpBrowserLogs ? 'verbose' : logLevel ?? 'info',
preferLossless: preferLossless ?? false,
indent: false,
onCtrlCExit: () => undefined,
diff --git a/packages/renderer/src/render-still.ts b/packages/renderer/src/render-still.ts
index face639e86..4bb25a1fb0 100644
--- a/packages/renderer/src/render-still.ts
+++ b/packages/renderer/src/render-still.ts
@@ -24,7 +24,6 @@ import {
} from './image-format';
import {DEFAULT_JPEG_QUALITY, validateJpegQuality} from './jpeg-quality';
import type {LogLevel} from './log-level';
-import {getLogLevel} from './logger';
import type {CancelSignal} from './make-cancel-signal';
import {cancelErrorMessages} from './make-cancel-signal';
import type {ChromiumOptions} from './open-browser';
@@ -98,6 +97,7 @@ export type RenderStillOptions = {
* @deprecated Use "logLevel" instead
*/
verbose?: boolean;
+ logLevel?: LogLevel;
serveUrl: string;
/**
* @deprecated Renamed to `jpegQuality`
@@ -437,6 +437,7 @@ export const renderStill = (
verbose,
quality,
offthreadVideoCacheSizeInBytes,
+ logLevel,
} = options;
if (typeof jpegQuality !== 'undefined' && imageFormat !== 'jpeg') {
@@ -477,7 +478,7 @@ export const renderStill = (
server: undefined,
serveUrl,
timeoutInMilliseconds: timeoutInMilliseconds ?? DEFAULT_TIMEOUT,
- logLevel: verbose || dumpBrowserLogs ? 'verbose' : getLogLevel(),
+ logLevel: logLevel ?? (verbose || dumpBrowserLogs ? 'verbose' : 'info'),
serializedResolvedPropsWithCustomSchema:
NoReactInternals.serializeJSONWithDate({
indent: undefined,
diff --git a/packages/studio/src/components/RenderModal/RenderModalAdvanced.tsx b/packages/studio/src/components/RenderModal/RenderModalAdvanced.tsx
index f4cf33e89b..97afd7a56c 100644
--- a/packages/studio/src/components/RenderModal/RenderModalAdvanced.tsx
+++ b/packages/studio/src/components/RenderModal/RenderModalAdvanced.tsx
@@ -249,7 +249,10 @@ export const RenderModalAdvanced: React.FC<{
return (
<div style={container} className={VERTICAL_SCROLLBAR_CLASSNAME}>
<div style={optionRow}>
- <div style={label}>Verbose logging</div>
+ <div style={label}>
+ Verbose logging <Spacing x={0.5} />
+ <OptionExplainerBubble id="logLevelOption" />
+ </div>
<div style={rightRow}>
<Checkbox
checked={logLevel === 'verbose'}