Skip to content

Commit

Permalink
Merge pull request #624 from salesforcecli/mdonnalley/bump-sf-plugins…
Browse files Browse the repository at this point in the history
…-core

feat: use new table
  • Loading branch information
soridalac authored Nov 8, 2024
2 parents 315eab3 + b066db3 commit 58229bb
Show file tree
Hide file tree
Showing 5 changed files with 293 additions and 65 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
8 changes: 5 additions & 3 deletions test/commands/apex/loggingCommands.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ describe('apex log *', () => {
});

it('will list the debug logs', async () => {
const result = execCmd('apex:list:log', { ensureExitCode: 0 }).shellOutput.stdout;
const result = execCmd('apex:list:log', { ensureExitCode: 0, env: { ...process.env, SF_NO_TABLE_STYLE: 'true' } })
.shellOutput.stdout;

expect(result).to.match(
/ Application Duration \(ms\) Id\s+Location\s+Size \(B\) Log User\s+Operation Request Start Time\s+Status /
/Application\s+Duration \(ms\)\s+Id\s+Location\s+Size \(B\)\s+Log User\s+Operation\s+Request\s+Start Time\s+Status/
);
expect(result).to.match(/User User Api\s+Api\s+\d{4}-\d{2}-.* Success /);
expect(result).to.match(/User User\s+Api\s+Api\s+\d{4}-\d{2}-.*\s+Success/);
});

it('will list the debug logs --json', async () => {
Expand Down
Loading

0 comments on commit 58229bb

Please sign in to comment.