Skip to content

Commit

Permalink
feat: use new table
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Nov 8, 2024
1 parent 315eab3 commit e8c6664
Show file tree
Hide file tree
Showing 4 changed files with 288 additions and 62 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@salesforce/apex-node": "^8.1.15",
"@salesforce/core": "^8.6.4",
"@salesforce/kit": "^3.2.2",
"@salesforce/sf-plugins-core": "^11.3.12",
"@salesforce/sf-plugins-core": "^12",
"ansis": "^3.3.1"
},
"devDependencies": {
Expand Down
30 changes: 16 additions & 14 deletions src/commands/apex/list/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,22 @@ export default class Log extends SfCommand<LogListResult> {

if (!flags.json) {
// while not required to prevent table output, save a few iterations if only printing json
this.table(logRecords.map(formatForTable), tableHeaders, { 'no-truncate': true });
this.table({
data: logRecords.map(formatForTable),
columns: [
'Application',
{ key: 'DurationMilliseconds', name: 'Duration (ms)' },
'Id',
'Location',
{ key: 'LogLength', name: 'Size (B)' },
{ key: 'User', name: 'Log User' },
'Operation',
'Request',
{ key: 'StartTime', name: 'Start Time' },
'Status',
],
overflow: 'wrap',
});
}

return logRecords;
Expand All @@ -65,16 +80,3 @@ const formatTime = (time: string): string => {
const msIndex = time.indexOf('.');
return msIndex !== -1 ? time.substring(0, msIndex) + time.substring(msIndex + 4) : time;
};

const tableHeaders = {
Application: { header: 'Application' },
DurationMilliseconds: { header: 'Duration (ms)' },
Id: { header: 'Id' },
Location: { header: 'Location' },
LogLength: { header: 'Size (B)' },
User: { header: 'Log User' },
Operation: { header: 'Operation' },
Request: { header: 'Request' },
StartTime: { header: 'Start Time' },
Status: { header: 'Status' },
};
24 changes: 9 additions & 15 deletions test/commands/apex/list/log.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,38 +80,32 @@ describe('apex:log:list', () => {
it('will list multiple logs', async () => {
sandbox.stub(LogService.prototype, 'getLogRecords').resolves(structuredClone(logRecords));
await Log.run([]);
expect(uxStub.table.args[0][0]).to.deep.equal([
expect(uxStub.table.args[0][0].data).to.deep.equal([
{
Id: '07L5tgg0005PGdTnEAL',
Application: 'Unknown',
DurationMilliseconds: '75',
Id: '07L5tgg0005PGdTnEAL',
Location: 'Unknown',
LogLength: 450,
LogUser: { Name: 'Test User', attributes: {} },
Operation: 'API',
Request: 'API',
LogLength: 450,
Status: 'Assertion Failed',
StartTime: '2020-10-13T05:39:43+0000',
Status: 'Assertion Failed',
User: 'Test User',
LogUser: {
Name: 'Test User',
attributes: {},
},
},
{
Id: '07L5tgg0005PGdTnFPL',
Application: 'Unknown',
DurationMilliseconds: '75',
Id: '07L5tgg0005PGdTnFPL',
Location: 'Unknown',
LogLength: 450,
LogUser: { Name: 'Test User2', attributes: {} },
Operation: 'API',
Request: 'API',
LogLength: 450,
Status: 'Successful',
StartTime: '2020-10-13T05:39:43+0000',
Status: 'Successful',
User: 'Test User2',
LogUser: {
Name: 'Test User2',
attributes: {},
},
},
]);
});
Expand Down
Loading

0 comments on commit e8c6664

Please sign in to comment.