{"record":{"id":"2e7f14c4e6ba921c","repo":"remotion-dev/remotion","slug":"useloglevel-must-be-used-within-a-loglevelprovider","errorCode":null,"errorMessage":"useLogLevel must be used within a LogLevelProvider","messagePattern":"useLogLevel must be used within a LogLevelProvider","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/log-level-context.tsx","lineNumber":18,"sourceCode":"import {createContext} from 'react';\nimport type {LogLevel} from './log';\nimport React = require('react');\n\nexport type LoggingContextValue = {\n\tlogLevel: LogLevel | null;\n\tmountTime: number;\n};\n\nexport const LogLevelContext = createContext<LoggingContextValue>({\n\tlogLevel: 'info',\n\tmountTime: 0,\n});\n\nexport const useLogLevel = (): LogLevel => {\n\tconst {logLevel} = React.useContext(LogLevelContext);\n\tif (logLevel === null) {\n\t\tthrow new Error('useLogLevel must be used within a LogLevelProvider');\n\t}\n\n\treturn logLevel;\n};\n\nexport const useMountTime = (): number => {\n\tconst {mountTime} = React.useContext(LogLevelContext);\n\tif (mountTime === null) {\n\t\tthrow new Error('useMountTime must be used within a LogLevelProvider');\n\t}\n\n\treturn mountTime;\n};\n","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/log-level-context.tsx#L1-L32","documentation":"Thrown by the useLogLevel() hook when the LogLevelContext value has logLevel === null. Because the context default sets logLevel to 'info', this only fires when a LogLevelProvider is rendered with an explicitly null/incomplete value (or a custom provider that sets it to null) — it indicates the provider has not supplied a real log level rather than the hook being used outside any tree.","triggerScenarios":"Rendering a LogLevelProvider whose value prop carries logLevel: null; a provider that forwards an uninitialized logLevel; using the hook under a custom provider that resets logLevel to null during initialization.","commonSituations":"Wiring a custom provider that reads log level from async config and sets null until loaded; resetting context state to null on logout/reset; partial context objects passed to the provider.","solutions":["Ensure the LogLevelProvider always supplies a concrete LogLevel (e.g. 'info') as its value.logLevel.","Default the provider's logLevel to 'info' while the real value is loading instead of null.","Use Remotion's built-in LogLevelProvider rather than a custom one."],"exampleFix":"// before\n<LogLevelContext.Provider value={{logLevel: null, mountTime: 0}}>\n  <App/>\n</LogLevelContext.Provider>\n// after\n<LogLevelContext.Provider value={{logLevel: 'info', mountTime: Date.now()}}>\n  <App/>\n</LogLevelContext.Provider>","handlingStrategy":"validation","validationCode":"const logLevel = useLogLevelSafe();\n// where useLogLevelSafe reads context and falls back to 'info' when null","typeGuard":"const isLogLevel = (v: unknown): v is string =>\n  typeof v === 'string' && ['verbose', 'info', 'warn', 'error'].includes(v);","tryCatchPattern":null,"preventionTips":["Always supply a concrete logLevel in your LogLevelProvider value.","Default to 'info' while the real level loads instead of null.","Prefer Remotion's built-in LogLevelProvider over a custom one."],"tags":["react","context","log-level","hooks"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}