Setup a new logger
This could help me to debug a few issues reported by some users using a rh1
This commit is contained in:
parent
a7a085546f
commit
bb09f51ad9
|
@ -15,7 +15,7 @@ import App from './components/app';
|
|||
import './index.css';
|
||||
import { FFMpegAudioExportService } from './services/audio-export';
|
||||
|
||||
serviceRegistry.netmdService = new NetMDUSBService();
|
||||
serviceRegistry.netmdService = new NetMDUSBService({ debug: true });
|
||||
// serviceRegistry.netmdService = new NetMDMockService(); // Uncomment to work without a device attached
|
||||
serviceRegistry.audioExportService = new FFMpegAudioExportService();
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { openNewDevice, NetMDInterface, Disc, listContent, openPairedDevice, Wireformat, MDTrack, download } from 'netmd-js';
|
||||
import { makeGetAsyncPacketIteratorOnWorkerThread } from 'netmd-js/dist/web-encrypt-worker';
|
||||
import { Logger, ConsoleLogger, Level } from 'netmd-js/dist/logger';
|
||||
|
||||
const Worker = require('worker-loader!netmd-js/dist/web-encrypt-worker.js'); // eslint-disable-line import/no-webpack-loader-syntax
|
||||
|
||||
|
@ -29,9 +30,28 @@ export interface NetMDService {
|
|||
|
||||
export class NetMDUSBService implements NetMDService {
|
||||
private netmdInterface?: NetMDInterface;
|
||||
private logger?: Logger;
|
||||
|
||||
constructor({ debug = false }: { debug: boolean }) {
|
||||
if (debug) {
|
||||
// Logging a few methods that have been causing issues with some units
|
||||
const _fn = (...args: any) => {
|
||||
if (args && args[0] && args[0].method) {
|
||||
console.log(...args);
|
||||
}
|
||||
};
|
||||
this.logger = {
|
||||
debug: _fn,
|
||||
info: _fn,
|
||||
warn: _fn,
|
||||
error: _fn,
|
||||
child: () => this.logger!,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async pair() {
|
||||
let iface = await openNewDevice(navigator.usb);
|
||||
let iface = await openNewDevice(navigator.usb, this.logger);
|
||||
if (iface === null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -40,7 +60,7 @@ export class NetMDUSBService implements NetMDService {
|
|||
}
|
||||
|
||||
async connect() {
|
||||
let iface = await openPairedDevice(navigator.usb);
|
||||
let iface = await openPairedDevice(navigator.usb, this.logger);
|
||||
if (iface === null) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue