Skip to content

🎥 Make videos programmatically with React

pass log levels

Jonny Burgercdbdfa77e266
diff --git a/packages/cli/src/log.ts b/packages/cli/src/log.ts
index 637f5a165d..a53b9a5229 100644
--- a/packages/cli/src/log.ts
+++ b/packages/cli/src/log.ts
@@ -2,7 +2,7 @@
import chalk from 'chalk';
-const logLevels = ['verbose', 'info', 'warn', 'error'] as const;
+export const logLevels = ['verbose', 'info', 'warn', 'error'] as const;
export type LogLevel = typeof logLevels[number];
diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.ts
index 146095882e..e36b6b3752 100644
--- a/packages/cli/src/parse-command-line.ts
+++ b/packages/cli/src/parse-command-line.ts
@@ -7,7 +7,7 @@ import {
Internals,
PixelFormat,
} from 'remotion';
-import {Log} from './log';
+import {isValidLogLevel, Log, LogLevel, logLevels, setLogLevel} from './log';
export type CommandLineOptions = {
['browser-executable']: BrowserExecutable;
@@ -25,6 +25,7 @@ export type CommandLineOptions = {
quality: number;
frames: string | number;
sequence: boolean;
+ log: string;
};
export const parsedCli = minimist<CommandLineOptions>(process.argv.slice(2));
@@ -44,6 +45,16 @@ export const parseCommandLine = () => {
parsedCli['bundle-cache'] === 'false' ? false : true
);
}
+ if (parsedCli.log) {
+ if (!isValidLogLevel(parsedCli.log)) {
+ Log.Error('Invalid `--log` value passed.');
+ Log.Error(
+ `Accepted values: ${logLevels.map((l) => `'${l}'`).join(', ')}.`
+ );
+ process.exit(1);
+ }
+ setLogLevel(parsedCli.log as LogLevel);
+ }
if (parsedCli.concurrency) {
Config.Rendering.setConcurrency(parsedCli.concurrency);
}