Skip to content

Commit

Permalink
Store logs in separate json files for each device
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed Nov 26, 2024
1 parent 8bb3704 commit ac886ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/cli/esim.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = ({ commandProcessor, root }) => {
description: 'Provide the input json file path'
},
'output': {
description: 'Provide the output json file path'
description: 'Provide the output folder path'
},
'binary': {
description: 'Provide the path to the binaries'
Expand Down
12 changes: 7 additions & 5 deletions src/cmd/esim.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = class ESimCommands extends CLICommandBase {
this.lpa = null;
this.inputJson = null;
this.inputJsonData = null;
this.outputJson = null;
this.outputFolder = null;
this.downloadedProfiles = [];
this.binaries = null;
this.verbose = false;
Expand All @@ -47,7 +47,8 @@ module.exports = class ESimCommands extends CLICommandBase {
const device = devices[0];
const resp = await this.doProvision(device);
await this._changeLed(device, resp.success ? PROVISIONING_SUCCESS : PROVISIONING_FAILURE);
this._addToJson(this.outputJson, resp);
const outputJsonForDevice = path.join(this.outputFolder, `${device.deviceId}.json`);
this._addToJson(outputJsonForDevice, resp);
}

async bulkProvisionCommand(args) {
Expand All @@ -61,9 +62,10 @@ module.exports = class ESimCommands extends CLICommandBase {
const deviceId = device.deviceId;
provisionedDevices.add(deviceId);
console.log(`Device ${deviceId} connected`);
const resp = await this.doProvision(device, { verbose: true });
const outputJsonForDevice = path.join(this.outputFolder, `${deviceId}.json`);
const resp = await this.doProvision(device, { verbose: false });
await this._changeLed(device, resp.success ? PROVISIONING_SUCCESS : PROVISIONING_FAILURE);
this._addToJson(this.outputJson, resp);
this._addToJson(outputJsonForDevice, resp);
}
}
}, 1000);
Expand Down Expand Up @@ -232,7 +234,7 @@ module.exports = class ESimCommands extends CLICommandBase {
const input = fs.readFileSync(this.inputJson);
this.inputJsonData = JSON.parse(input);

this.outputJson = args.output;
this.outputFolder = args.output;
this.lpa = args.lpa;
this.binaries = args.binary;
}
Expand Down

0 comments on commit ac886ad

Please sign in to comment.