feat: address log level feedback

This commit is contained in:
Eli Bosley
2025-01-23 16:40:04 -05:00
parent cbb42dc85e
commit bb95795a31
2 changed files with 6 additions and 8 deletions

View File

@@ -12,6 +12,8 @@ export const levels = [
'fatal', 'fatal',
] as const; ] as const;
export type LogLevel = typeof levels[number];
const level = const level =
levels[ levels[
levels.indexOf( levels.indexOf(

View File

@@ -2,14 +2,11 @@ import { execa } from 'execa';
import { Command, CommandRunner, Option } from 'nest-commander'; import { Command, CommandRunner, Option } from 'nest-commander';
import { ECOSYSTEM_PATH, PM2_PATH } from '@app/consts'; import { ECOSYSTEM_PATH, PM2_PATH } from '@app/consts';
import { levels } from '@app/core/log'; import { levels, LogLevel } from '@app/core/log';
import { LogService } from '@app/unraid-api/cli/log.service'; import { LogService } from '@app/unraid-api/cli/log.service';
interface StartCommandOptions { interface StartCommandOptions {
debug?: boolean;
port?: string;
'log-level'?: string; 'log-level'?: string;
environment?: string;
} }
@Command({ name: 'start' }) @Command({ name: 'start' })
@@ -39,10 +36,9 @@ export class StartCommand extends CommandRunner {
@Option({ @Option({
flags: `--log-level <${levels.join('|')}>`, flags: `--log-level <${levels.join('|')}>`,
description: 'log level to use', description: 'log level to use',
defaultValue: 'info',
}) })
parseLogLevel(val: string): typeof levels { parseLogLevel(val: string): LogLevel {
return (levels.includes(val as (typeof levels)[number]) return levels.includes(val as LogLevel) ? (val as LogLevel) : 'info';
? (val as (typeof levels)[number])
: 'info') as unknown as typeof levels;
} }
} }