Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 22
fix: Revert "fix(cli): support --log-level for start and restart cmds"#1663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,14 @@ | ||
| import { Command, CommandRunner, Option } from 'nest-commander'; | ||
| import type { LogLevel } from '@app/core/log.js'; | ||
| import type { LogLevelOptions } from '@app/unraid-api/cli/restart.command.js'; | ||
| import { levels } from '@app/core/log.js'; | ||
| import { ECOSYSTEM_PATH, LOG_LEVEL } from '@app/environment.js'; | ||
| import { ECOSYSTEM_PATH } from '@app/environment.js'; | ||
| import { LogService } from '@app/unraid-api/cli/log.service.js'; | ||
| import { PM2Service } from '@app/unraid-api/cli/pm2.service.js'; | ||
| import { parseLogLevelOption } from '@app/unraid-api/cli/restart.command.js'; | ||
| interface StartCommandOptions { | ||
| 'log-level'?: string; | ||
| } | ||
| @Command({ name: 'start', description: 'Start the Unraid API' }) | ||
| export class StartCommand extends CommandRunner { | ||
| @@ -25,12 +27,17 @@ export class StartCommand extends CommandRunner { | ||
| await this.pm2.run({ tag: 'PM2 Delete' }, 'delete', ECOSYSTEM_PATH); | ||
| } | ||
| async run(_: string[], options: LogLevelOptions): Promise<void> { | ||
| async run(_: string[], options: StartCommandOptions): Promise<void> { | ||
| this.logger.info('Starting the Unraid API'); | ||
| await this.cleanupPM2State(); | ||
| const env = { LOG_LEVEL: options.logLevel }; | ||
| const env: Record<string, string> = {}; | ||
| if (options['log-level']) { | ||
| env.LOG_LEVEL = options['log-level']; | ||
| } | ||
Comment on lines
+34
to
+37
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Only inject LOG_LEVEL when the flag is provided. With - if (options['log-level']) {+ if (typeof options['log-level'] !== 'undefined') {
env.LOG_LEVEL = options['log-level'];
}And remove the default to ensure absence when not passed: @Option({
flags: `--log-level <${levels.join('|')}>`,
description: 'log level to use',
- defaultValue: 'info',
})Also applies to: 57-57 🤖 Prompt for AI Agents | ||
| const { stderr, stdout } = await this.pm2.run( | ||
| { tag: 'PM2 Start', raw: true, extendEnv: true, env }, | ||
| { tag: 'PM2 Start', env, raw: true }, | ||
| 'start', | ||
| ECOSYSTEM_PATH, | ||
| '--update-env' | ||
| @@ -47,9 +54,9 @@ export class StartCommand extends CommandRunner { | ||
| @Option({ | ||
| flags: `--log-level <${levels.join('|')}>`, | ||
| description: 'log level to use', | ||
| defaultValue: LOG_LEVEL.toLowerCase(), | ||
| defaultValue: 'info', | ||
| }) | ||
| parseLogLevel(val: string): LogLevel { | ||
| return parseLogLevelOption(val); | ||
| return levels.includes(val as LogLevel) ? (val as LogLevel) : 'info'; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document all supported levels (missing
fatal).Code accepts
fatal(seelevels), but docs omit it. Add for accuracy.📝 Committable suggestion
🤖 Prompt for AI Agents