feat: overhaul config loading

This commit is contained in:
Aarnav Tale
2025-12-01 02:46:22 -05:00
parent d3d7c7cc0e
commit 86184e3420
26 changed files with 903 additions and 1134 deletions
+18 -2
View File
@@ -14,10 +14,11 @@ export interface Logger
debugEnabled: boolean;
}
const logLevels = getLogLevels();
export default {
debugEnabled: true,
debugEnabled: logLevels.includes('debug'),
...Object.fromEntries(
levels.map((level) => [
logLevels.map((level) => [
level,
(category: Category, message: string, ...args: unknown[]) => {
const date = new Date().toISOString();
@@ -29,3 +30,18 @@ export default {
]),
),
} as Logger;
function getLogLevels() {
const debugLog = process.env.HEADPLANE_DEBUG_LOG;
if (debugLog == null) {
return ['info', 'warn', 'error'];
}
const normalized = debugLog.trim().toLowerCase();
const truthyValues = ['1', 'true', 'yes', 'on'];
if (!truthyValues.includes(normalized)) {
return ['info', 'warn', 'error'];
}
return ['info', 'warn', 'error', 'debug'];
}