diff --git a/packages/uhk-common/src/log/get-log-options.ts b/packages/uhk-common/src/log/get-log-options.ts index 7339ebe2ea3..998cc1af357 100644 --- a/packages/uhk-common/src/log/get-log-options.ts +++ b/packages/uhk-common/src/log/get-log-options.ts @@ -7,6 +7,10 @@ export function getLogOptions(options: CommandLineArgs): LogOptions { return DEFAULT_LOG_OPTIONS; } + if (options.log === 'none') { + return {}; + } + return options.log .split(',') .reduce((logOptions, category) => { diff --git a/packages/usb/src/parse-logging-options.ts b/packages/usb/src/parse-logging-options.ts deleted file mode 100644 index e6b09e65fc0..00000000000 --- a/packages/usb/src/parse-logging-options.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { LogOptions } from 'uhk-common'; - -export function parseLoggingOptions(arg: string = ''): LogOptions { - return arg.split(',') - .reduce((logOptions, category) => { - switch (category) { - case 'all': - logOptions.config = true; - logOptions.misc = true; - logOptions.usb = true; - break; - - case 'config': - logOptions.config = true; - break; - - case 'misc': - logOptions.misc = true; - break; - - case 'usb': - logOptions.usb = true; - break; - - default: - break; - } - - return logOptions; - }, {} as LogOptions); - -} diff --git a/packages/usb/src/uhk.ts b/packages/usb/src/uhk.ts index 769ec18b776..795120b3da6 100644 --- a/packages/usb/src/uhk.ts +++ b/packages/usb/src/uhk.ts @@ -1,9 +1,7 @@ import { join } from 'desm'; -import { LogService } from 'uhk-common'; +import { getLogOptions, LogService } from 'uhk-common'; import { UhkHidDevice, UhkOperations } from 'uhk-usb'; -import { parseLoggingOptions } from './parse-logging-options.js'; - export interface Uhk { device: UhkHidDevice; logger: LogService; @@ -15,7 +13,7 @@ const rootDir = join(import.meta.url, '../../tmp'); export default function (argv: any): Uhk { const logger = new LogService(); - logger.setLogOptions(parseLoggingOptions(argv.log)); + logger.setLogOptions(getLogOptions(argv)); const device = new UhkHidDevice(logger, argv, rootDir); const operations = new UhkOperations(logger, device);