diff --git a/src/backend/common/logging.ts b/src/backend/common/logging.ts index 87c19766..a8910155 100644 --- a/src/backend/common/logging.ts +++ b/src/backend/common/logging.ts @@ -38,7 +38,8 @@ export const componentFileLogger = async (type: string, name: string, fileConfig logDefaultPath: './scrobble.log' }); - const base = path.dirname(typeof opts.file.path === 'function' ? opts.file.path() : opts.file.path!); + const filePath = typeof opts.file.path === 'function' ? opts.file.path() : opts.file.path; + const base = filePath !== undefined ? path.dirname(filePath) : logPath; const componentLogPath = path.join(base, `${type}-${name}.log`); const componentConfig: LogOptions = { @@ -62,8 +63,11 @@ export const componentFileLogger = async (type: string, name: string, fileConfig const streams: LogLevelStreamEntry[] = []; if(strongOpts.file.level !== false) { - const file = await buildDestinationRollingFile((componentConfig.file.level ?? componentConfig.level)!, {...strongOpts.file}) - streams.push(file!); + const file = await buildDestinationRollingFile(strongOpts.file.level, {...strongOpts.file}) + if(file === undefined) { + throw new Error('Could not build rolling file log destination'); + } + streams.push(file); return buildLogger('trace' as LogLevel, streams); } else {