Skip to content

Commit

Permalink
Enhancements for logEntryEventStream LWC (#337)
Browse files Browse the repository at this point in the history
* Closed #293 - new logEntryEventStream enhancements to add split-view toggling, add full-screen mode, and add a tabular view (with fields configurable via LoggerParameter.LogEntryEventStreamDisplayFields)

* Removed some problematic system log entries in LogEntryEventHandler

* Updated some GitHub actions in build.yml to use the latest versions
  • Loading branch information
mar-ben authored Nov 22, 2022
1 parent 81ce8b9 commit 956205d
Show file tree
Hide file tree
Showing 19 changed files with 622 additions and 181 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -98,11 +98,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -130,11 +130,11 @@ jobs:
environment: 'Base Scratch Org'
steps:
- name: 'Checkout source code'
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -191,11 +191,11 @@ jobs:
environment: 'Experience Cloud Scratch Org'
steps:
- name: 'Checkout source code'
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -265,13 +265,13 @@ jobs:
environment: 'Demo Org'
steps:
- name: 'Checkout source code'
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -305,13 +305,13 @@ jobs:
environment: 'Demo Org'
steps:
- name: 'Checkout source code'
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -374,11 +374,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

The most robust logger for Salesforce. Works with Apex, Lightning Components, Flow, Process Builder & Integrations. Designed for Salesforce admins, developers & architects.

## Unlocked Package - v4.9.1
## Unlocked Package - v4.9.2

[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000023R79QAE)
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000023R79QAE)
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000023R7iQAE)
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000023R7iQAE)
[![View Documentation](./images/btn-view-documentation.png)](https://jongpie.github.io/NebulaLogger/)

## Managed Package - v4.9.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<CustomMetadata
xmlns="http://soap.sforce.com/2006/04/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<label>Log Entry Event Stream Display Fields</label>
<protected>false</protected>
<values>
<field>Description__c</field>
<value xsi:type="xsd:string">Contains the fields to be displayed in the Tabular view of the Log Entry Event Stream Tab under the Logger Console.</value>
</values>
<values>
<field>Value__c</field>
<value
xsi:type="xsd:string"
>[&quot;Timestamp__c&quot;, &quot;LoggedByUsername__c&quot;, &quot;OriginLocation__c&quot;, &quot;LoggingLevel__c&quot;, &quot;Message__c&quot;]</value>
</values>
</CustomMetadata>
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,6 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler {

@future(callout=true)
private static void setStatusApiDetails() {
if (LoggerParameter.ENABLE_SYSTEM_MESSAGES == true) {
Logger.debug('Logger - Calling Status API for org details');
}

Organization organization = LoggerEngineDataSelector.getInstance().getCachedOrganization();
String statusApiEndpoint = 'https://api.status.salesforce.com/v1/instances/' + organization.InstanceName + '/status';

Expand All @@ -661,7 +657,6 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler {
request.setMethod('GET');

HttpResponse response = new Http().send(request);

if (response.getStatusCode() >= 400) {
String errorMessage =
'Callout failed for ' +
Expand All @@ -674,10 +669,6 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler {
}

StatusApiResponse statusApiResponse = (StatusApiResponse) JSON.deserialize(response.getBody(), StatusApiResponse.class);
if (LoggerParameter.ENABLE_SYSTEM_MESSAGES == true) {
Logger.debug('Logger - Status API response: ' + statusApiResponse);
}

List<Log__c> logsToUpdate = new List<Log__c>();
for (Log__c log : [
SELECT Id
Expand All @@ -691,13 +682,7 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler {

logsToUpdate.add(log);
}

if (LoggerParameter.ENABLE_SYSTEM_MESSAGES == true) {
Logger.debug('Logger - logs to update: ' + logsToUpdate);
}

LoggerDataStore.getDatabase().updateRecords(logsToUpdate);
Logger.saveLog();
}

// Private class for handling the response from api.status.salesforce.com
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//------------------------------------------------------------------------------------------------//
// This file is part of the Nebula Logger project, released under the MIT License. //
// See LICENSE file or go to https://github.com/jongpie/NebulaLogger for full license details. //
//------------------------------------------------------------------------------------------------//

/**
* @group Log Management
* @description Controller class for lwc `logEntryEventStream`, used to stream Log Entries in console and Tabular view.
*/
@SuppressWarnings('PMD.ApexCRUDViolation, PMD.CyclomaticComplexity, PMD.ExcessivePublicCount')
public with sharing class LogEntryEventStreamController {
@TestVisible
private static final String DISPLAY_FIELDS_PARAMETER_NAME = 'LogEntryEventStreamDisplayFields';
@TestVisible
private static final List<String> DEFAULT_DISPLAY_FIELDS = new List<String>{
Schema.LogEntryEvent__e.Timestamp__c.getDescribe().getLocalName(),
Schema.LogEntryEvent__e.LoggedByUsername__c.getDescribe().getLocalName(),
Schema.LogEntryEvent__e.OriginLocation__c.getDescribe().getLocalName(),
Schema.LogEntryEvent__e.LoggingLevel__c.getDescribe().getLocalName(),
Schema.LogEntryEvent__e.Message__c.getDescribe().getLocalName()
};
/**
* @description Returns the list of columns to be displayed in
* LogEntryEventStream Datatable. The fields are configured
* in the Custom Meta Data (LoggerParameter.LogEntryEventStreamDisplayFields).
* @return The instance of `List<String>`, containing the list of columns to be displayed in
* LogEntryEventStream Datatable .
*/
@AuraEnabled
public static List<String> getDatatableDisplayFields() {
try {
return LoggerParameter.getStringList(DISPLAY_FIELDS_PARAMETER_NAME, DEFAULT_DISPLAY_FIELDS);
} catch (Exception e) {
throw new AuraHandledException(e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>56.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ describe('logBatchPurge lwc tests', () => {
const runPurgeBatch = logBatchPurgeElement.shadowRoot.querySelector('lightning-button[data-id="run-purge-button"]');
expect(runPurgeBatch).toBeTruthy();

const purgeBatchJobsDataTable = logBatchPurgeElement.shadowRoot.querySelector('lightning-datatable[data-id="purge-batch-jobs"');
expect(purgeBatchJobsDataTable).toBeTruthy();
expect(purgeBatchJobsDataTable.data).toEqual(mockGetPurgeBatchJobRecords);
const purgeBatchJobsDatatable = logBatchPurgeElement.shadowRoot.querySelector('lightning-datatable[data-id="purge-batch-jobs"');
expect(purgeBatchJobsDatatable).toBeTruthy();
expect(purgeBatchJobsDatatable.data).toEqual(mockGetPurgeBatchJobRecords);
});

it('displays log metrics for today by default', async () => {
Expand Down Expand Up @@ -331,9 +331,9 @@ describe('logBatchPurge lwc tests', () => {
it('displays the purge job records in datatable.', async () => {
const logBatchPurgeElement = await initializeElement(true);

const purgeBatchJobsDataTable = logBatchPurgeElement.shadowRoot.querySelector('lightning-datatable[data-id="purge-batch-jobs"');
expect(purgeBatchJobsDataTable).toBeTruthy();
expect(purgeBatchJobsDataTable.data).toEqual(mockGetPurgeBatchJobRecords);
const purgeBatchJobsDatatable = logBatchPurgeElement.shadowRoot.querySelector('lightning-datatable[data-id="purge-batch-jobs"');
expect(purgeBatchJobsDatatable).toBeTruthy();
expect(purgeBatchJobsDatatable.data).toEqual(mockGetPurgeBatchJobRecords);
});

it('it show success toast when user click on run batch button.', async () => {
Expand All @@ -357,10 +357,10 @@ describe('logBatchPurge lwc tests', () => {
await Promise.resolve('resolves loadpurgeBatchJobRecords()');
await Promise.resolve('resolves canUserRunLogBatchPurger()');

const purgeBatchJobsDataTable = logBatchPurgeElement.shadowRoot.querySelector('lightning-datatable[data-id="purge-batch-jobs"');
expect(purgeBatchJobsDataTable).toBeTruthy();
const purgeBatchJobsDatatable = logBatchPurgeElement.shadowRoot.querySelector('lightning-datatable[data-id="purge-batch-jobs"');
expect(purgeBatchJobsDatatable).toBeTruthy();

expect(purgeBatchJobsDataTable.data).toEqual(mockGetPurgeBatchJobRecords);
expect(purgeBatchJobsDatatable.data).toEqual(mockGetPurgeBatchJobRecords);
});

it('it refresh the purge batch records for every 10 sec.', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["Timestamp__c", "LoggedByUsername__c"]
Loading

0 comments on commit 956205d

Please sign in to comment.