mirror of
https://github.com/unraid/api.git
synced 2025-12-31 21:49:57 -06:00
feat: address log level feedback
This commit is contained in:
@@ -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(
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user