Skip to content

Commit

Permalink
Merge pull request #2446 from UltimateHackingKeyboard/chore-unify-log…
Browse files Browse the repository at this point in the history
…-optins-parsing

refactor: unify log option parser of agent and usb scripts
  • Loading branch information
mondalaci authored Dec 15, 2024
2 parents f3bf32b + 28a9fac commit 677118b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 36 deletions.
4 changes: 4 additions & 0 deletions packages/uhk-common/src/log/get-log-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
32 changes: 0 additions & 32 deletions packages/usb/src/parse-logging-options.ts

This file was deleted.

6 changes: 2 additions & 4 deletions packages/usb/src/uhk.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 677118b

Please sign in to comment.