Tests for common/logger * chore: add tests for createLogger * chore: add tests for createLogger Approved-by: Linus Flood
20 lines
502 B
TypeScript
20 lines
502 B
TypeScript
import { logLevels } from "./logLevels"
|
|
|
|
export const minimumLogLevel = (() => {
|
|
const configuredMinimumLogLevel = (
|
|
(process.env.MINIMUM_LOG_LEVEL ||
|
|
process.env.NEXT_PUBLIC_MINIMUM_LOG_LEVEL) ??
|
|
"info"
|
|
).toLowerCase() as (typeof logLevels)[number]
|
|
|
|
if (!logLevels.includes(configuredMinimumLogLevel)) {
|
|
console.warn(
|
|
`Invalid log level configured: ${configuredMinimumLogLevel}, defaulting to 'info'`
|
|
)
|
|
|
|
return "info"
|
|
}
|
|
|
|
return configuredMinimumLogLevel
|
|
})()
|