Skip to content

🎥 Make videos programmatically with React

infra for logging in player

Jonny Burger0e1bc29e729f
diff --git a/packages/core/src/use-buffer-state.ts b/packages/core/src/use-buffer-state.ts
index fe45b91b66..ec94a72ea2 100644
--- a/packages/core/src/use-buffer-state.ts
+++ b/packages/core/src/use-buffer-state.ts
@@ -1,5 +1,7 @@
import {useContext, useMemo} from 'react';
import {BufferingContextReact} from './buffering';
+import {Log} from './log';
+import {useLogLevel} from './log-level-context';
export type DelayPlaybackHandle = {
unblock: () => void;
@@ -11,6 +13,7 @@ export type UseBufferState = {
export const useBufferState = (): UseBufferState => {
const buffer = useContext(BufferingContextReact);
+ const logLevel = useLogLevel();
// Allows <Img> tag to be rendered without a context
// https://github.com/remotion-dev/remotion/issues/4007
@@ -25,13 +28,23 @@ export const useBufferState = (): UseBufferState => {
);
}
+ Log.trace({logLevel, tag: '[buffer-state]'}, 'Adding buffer handle');
+
const {unblock} = addBlock({
id: String(Math.random()),
});
- return {unblock};
+ return {
+ unblock: () => {
+ Log.trace(
+ {logLevel, tag: '[buffer-state]'},
+ 'Removing buffer handle',
+ );
+ unblock();
+ },
+ };
},
}),
- [addBlock],
+ [addBlock, logLevel],
);
};
diff --git a/packages/docs/components/demos/index.tsx b/packages/docs/components/demos/index.tsx
index be56f1c3c4..9c3579a93a 100644
--- a/packages/docs/components/demos/index.tsx
+++ b/packages/docs/components/demos/index.tsx
@@ -157,6 +157,7 @@ export const Demo: React.FC<{
? '1px solid var(--ifm-color-emphasis-300)'
: 0,
}}
+ logLevel={demo.logLevel}
errorFallback={({error}) => {
return (
<AbsoluteFill
diff --git a/packages/docs/components/demos/types.ts b/packages/docs/components/demos/types.ts
index 30b12e3bd8..018458feeb 100644
--- a/packages/docs/components/demos/types.ts
+++ b/packages/docs/components/demos/types.ts
@@ -1,3 +1,4 @@
+import type {LogLevel} from 'remotion';
import {
ClockWipeDemo,
CubeDemo,
@@ -18,8 +19,6 @@ import {HeartDemo} from './Heart';
import {HtmlInCanvasDocsDemo2DBlur} from './HtmlInCanvasDocsDemo2DBlur';
import {HtmlInCanvasDocsDemoWebGL} from './HtmlInCanvasDocsDemoWebGL';
import {HtmlInCanvasDocsDemoWebGPU} from './HtmlInCanvasDocsDemoWebGPU';
-import {ZoomBlurDocsDemo} from './ZoomBlurDemo';
-import {ZoomInOutDocsDemo} from './ZoomInOutDemo';
import {LightLeakDemoComp} from './LightLeakDemo';
import {NoiseComp} from './NoiseDemo';
import {PieDemo} from './Pie';
@@ -42,6 +41,8 @@ import {
TranslateDemo,
} from './Translate';
import {TriangleDemo} from './Triangle';
+import {ZoomBlurDocsDemo} from './ZoomBlurDemo';
+import {ZoomInOutDocsDemo} from './ZoomInOutDemo';
export type Option = {
name: string;
@@ -80,6 +81,7 @@ export type DemoType = {
options: Option[];
autoPlay: boolean;
controls: boolean;
+ logLevel: LogLevel;
};
export const arrowDemo: DemoType = {
@@ -91,6 +93,8 @@ export const arrowDemo: DemoType = {
id: 'arrow',
autoPlay: false,
controls: false,
+ logLevel: 'info',
+ logLevel: 'info',
options: [
{
default: 300,
@@ -156,6 +160,7 @@ export const rectDemo: DemoType = {
id: 'rect',
autoPlay: false,
controls: false,
+ logLevel: 'info',
options: [
{
default: 200,
@@ -211,6 +216,7 @@ export const triangleDemo: DemoType = {
id: 'triangle',
autoPlay: false,
controls: false,
+ logLevel: 'info',
options: [
{
default: 200,
@@ -264,6 +270,7 @@ export const circleDemo: DemoType = {
id: 'circle',
autoPlay: false,
controls: false,
+ logLevel: 'info',
options: [
{
default: 200,
@@ -286,6 +293,7 @@ export const heartDemo: DemoType = {
id: 'heart',
autoPlay: false,
controls: false,
+ logLevel: 'info',
options: [
{
default: 300,
@@ -342,6 +350,7 @@ export const translateDemo: DemoType = {
comp: TranslateDemo,
autoPlay: false,
controls: false,
+ logLevel: 'info',
compHeight: 400,
compWidth: 1280,
durationInFrames: 150,
@@ -373,6 +382,7 @@ export const skewDemo: DemoType = {
comp: SkewDemo,
autoPlay: false,
controls: false,
+ logLevel: 'info',
compHeight: 400,
compWidth: 1280,
durationInFrames: 150,
@@ -395,6 +405,7 @@ export const scaleDemo: DemoType = {
comp: ScaleDemo,
autoPlay: false,
controls: false,
+ logLevel: 'info',
compHeight: 400,
compWidth: 1280,
durationInFrames: 150,
@@ -417,6 +428,7 @@ export const opacityDemo: DemoType = {
comp: OpacityDemo,
autoPlay: false,
controls: false,
+ logLevel: 'info',
compHeight: 400,
compWidth: 1280,
durationInFrames: 150,
@@ -439,6 +451,7 @@ export const rotateDemo: DemoType = {
comp: RotateDemo,
autoPlay: false,
controls: false,
+ logLevel: 'info',
compHeight: 400,
compWidth: 1280,
durationInFrames: 150,
@@ -466,6 +479,7 @@ export const pieDemo: DemoType = {
id: 'pie',
autoPlay: false,
controls: false,
+ logLevel: 'info',
options: [
{
default: 200,
@@ -524,6 +538,7 @@ export const ellipseDemo: DemoType = {
id: 'ellipse',
autoPlay: false,
controls: false,
+ logLevel: 'info',
options: [
{
default: 150,
@@ -554,6 +569,7 @@ export const polygonDemo: DemoType = {
id: 'polygon',
autoPlay: false,
controls: false,
+ logLevel: 'info',
options: [
{
default: 3,
@@ -603,6 +619,7 @@ export const starDemo: DemoType = {
id: 'star',
autoPlay: false,
controls: false,
+ logLevel: 'info',
options: [
{
default: 100,
@@ -661,6 +678,7 @@ export const noiseDemo: DemoType = {
id: 'noise',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [
{
default: 0.01,
@@ -701,6 +719,7 @@ export const fadePresentationDemo: DemoType = {
id: 'fade',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [],
};
@@ -713,6 +732,7 @@ export const slidePresentationDemo: DemoType = {
id: 'slide',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [
{
type: 'enum',
@@ -732,6 +752,7 @@ export const flipPresentationDemo: DemoType = {
id: 'flip',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [
{
type: 'enum',
@@ -752,6 +773,7 @@ export const nonePresentationDemo: DemoType = {
id: 'none',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [],
};
@@ -764,6 +786,7 @@ export const slidePresentationDemoLongThreshold: DemoType = {
id: 'slide-long-duration-rest',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [],
};
@@ -776,6 +799,7 @@ export const wipePresentationDemo: DemoType = {
id: 'wipe',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [
{
type: 'enum',
@@ -805,6 +829,7 @@ export const roundedTextBoxDemo: DemoType = {
id: 'rounded-text-box',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [
{
type: 'enum',
@@ -859,6 +884,7 @@ export const clockWipePresentationDemo: DemoType = {
id: 'clock-wipe',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [],
};
@@ -871,6 +897,7 @@ export const irisPresentationDemo: DemoType = {
id: 'iris',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [],
};
@@ -883,6 +910,7 @@ export const cubePresentationDemo: DemoType = {
id: 'cube',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [
{
type: 'enum',
@@ -903,6 +931,7 @@ export const zoomBlurPresentationDemo: DemoType = {
id: 'zoom-blur',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [],
};
@@ -915,6 +944,7 @@ export const zoomInOutPresentationDemo: DemoType = {
id: 'zoom-in-out',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [],
};
@@ -927,6 +957,7 @@ export const customPresentationDemo: DemoType = {
id: 'custom-presentation',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [],
};
@@ -939,6 +970,7 @@ export const customTimingDemo: DemoType = {
id: 'custom-timing',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [],
};
@@ -951,6 +983,7 @@ export const animationMathDemo: DemoType = {
id: 'animation-math',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [],
};
@@ -963,6 +996,7 @@ export const springDemo: DemoType = {
id: 'spring',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [
{
name: 'damping',
@@ -1024,6 +1058,7 @@ export const shaderDemo: DemoType = {
id: 'shader',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [],
};
@@ -1036,6 +1071,7 @@ export const springDampingDemo: DemoType = {
id: 'spring-damping',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [
{
name: 'damping',
@@ -1089,6 +1125,7 @@ export const starburstDemo: DemoType = {
id: 'starburst',
autoPlay: false,
controls: false,
+ logLevel: 'info',
options: [
{
name: 'rays',
@@ -1156,6 +1193,7 @@ export const transitionSeriesTransitionDemo: DemoType = {
id: 'transition-series-transition',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [
{
name: 'presentation',
@@ -1216,6 +1254,7 @@ export const transitionSeriesEnterExitDemo: DemoType = {
id: 'transition-series-enter-exit',
autoPlay: true,
controls: false,
+ logLevel: 'info',
options: [
{
name: 'presentation',
@@ -1236,6 +1275,7 @@ export const htmlInCanvasDemo2DBlur: DemoType = {
id: 'html-in-canvas-2d-blur',
autoPlay: true,
controls: true,
+ logLevel: 'info',
options: [],
};
@@ -1248,6 +1288,7 @@ export const htmlInCanvasDemoWebGL: DemoType = {
id: 'html-in-canvas-webgl',
autoPlay: true,
controls: true,
+ logLevel: 'info',
options: [],
};
@@ -1260,5 +1301,6 @@ export const htmlInCanvasDemoWebGPU: DemoType = {
id: 'html-in-canvas-webgpu',
autoPlay: true,
controls: true,
+ logLevel: 'info',
options: [],
};