Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Log__c & LoggerSettings__c fields #218

Merged
merged 34 commits into from
Oct 14, 2021
Merged

New Log__c & LoggerSettings__c fields #218

merged 34 commits into from
Oct 14, 2021

Conversation

jongpie
Copy link
Owner

@jongpie jongpie commented Oct 6, 2021

New field Log__c.Scenario__c

Closes #217 by adding a new field, Log__c.Scenario__c, that can be set via Apex, Flow and lightning components. This field is provided as a way for org's to self-identify the context of the current transaction. It fully relies on the org's metadata to handle setting this - nothing within Nebula Logger automatically sets this field. In the event that the scenario is set multiple times in a single transaction, then the last scenario specified will be the value used for Log__c.Scenario__c.

Conceptually, this serves a similar purpose to the tagging system - however, tagging is more focused on identifying certain LogEntry__c records, where as the Scenario field is focused on identifying a particular Log__c record.

Scenario Field Tagging System
Object Log__c object - stored in Log__.Scenario__c LogEntry__c object - related via LogEntryTag__c junction object
Usage Only 1 scenario can be stored per transaction/Log__c record Supports adding multiple tags to each LogEntry__c record

Specifying Scenario in Apex

When logging from within Apex, simply call the method Logger.setScenario(String scenario) before calling Logger.saveLog() to specify the current transaction's scenario.

Logger.info('some log entry created BEFORE specifying a scenario'); // This log entry will still have the scenario set, even though it's logged before `setScenario(String)` is called
Logger.setScenario('an example transaction scenario name');
Logger.info('some log entry created AFTER specifying a scenario');
Logger.saveLog();

Specifying Scenario in Lightning Components

When logging from within lightning web components and aura components, you can specify the scenario by calling the logger function setScenario(scenario) - this function expects a String to be passed as the parameter. This example shows a basic example of how you can specify the log's scenario and save any pending log entries.

saveLogExample() {
    const logger = this.template.querySelector('c-logger');
    logger.setScenario('some.scenario');
    logger.saveLog();
}

Specifying Scenario in Flow

With adding a log entry from Flow, you can now optionally set the transaction's scenario, using the provided property Scenario - this property is available in all 3 Flow classes (FlowLogEntry, FlowRecordLogEntry, and FlowCollectionLogEntry).

image

Scenario Field in Log__c List Views

The new Scenario__c field is now included in the "All Logs" list view - you can also add the new field to any of your own list views.

image

Scenario Field on Log__c Detail Page

The new Scenario__c field is also included on the Log__c record's detail page, under the section "Log Management"

image

Manually Updating the Scenario Field via Log's "Manage" Quick Action

In some situations, you may want to manually change the value of the field Log__c.Scenario__c - this can now be done using the "Manage" quick action. Simply click the "Manage" button on a Log__c record (or select multiple logs from a list view and click "Manage"), and you can then update the field's value.

image

New field Log__c.LoggerVersionNumber__c

Another field has also been included to store which version of Nebula Logger created the Log__c record. This will will be helpful in trying to troubleshoot any issues/questions with logging. It also provides a way to know which version is deployed to orgs that are using the unpackaged metadata instead of the unlocked or managed packages (i.e., the metadata has been deployed directly to an org).

image

New LoggerSettings__c fields

Added 2 new LoggerSettings__c fields to provide a little more control. Both are enabled by default, but to help with performance, these settings should typically be disabled in production unless you are actively troubleshooting an issue.

  • IsApexSystemDebugLoggingEnabled__c - When enabled, Logger will automatically call Apex's System.debug() when logging via Apex, Flow/Process Builder, or Lightning Components
  • IsComponentConsoleLoggingEnabled__c - When enabled, Logger will automatically call the browser's console.log() function when logging via Lightning Components

LogBatchPurger Enhancement

Closed #223 by adding an extra filter in LogBatchPurger so that any Log__c records with 0 log entries will be deleted, regardless of log's the retention date

Auth.RegistrationHandler Logging Bugfix

Code Quality & Pipeline Enhancements

A few other changes have been included to improve the overall code quality:

  • Enabled more ESlint rules for lwc & aura, fixed several reported issues
  • Enabled more PMD rules for Apex, fixed several reported issues
  • Automated creating unlocked package version and updating sfdx-project.json + README.md
  • Added check in pipeline to verify that the current package version number hasn't already been released
  • Added check in pipeline to verify that Apex docs have been generated & committed

@jongpie jongpie added Type: Enhancement New feature or request Logging Source: Apex Items related to using Logger within Apex Logging Source: Flow Items related to using Nebula Logger within Flow Logging Source: Lightning Components Items related to using Nebula Logger using JavaScript within lightning components (lwc & aura) Layer: Log Management Items related to the custom objects & Logger Console app Layer: Logger Engine Items related to the core logging engine labels Oct 6, 2021
@jongpie jongpie temporarily deployed to Test October 6, 2021 07:33 Inactive
@jongpie jongpie temporarily deployed to Test October 6, 2021 07:36 Inactive
@jongpie jongpie temporarily deployed to Test October 6, 2021 07:36 Inactive
@jongpie jongpie temporarily deployed to Test October 6, 2021 07:44 Inactive
@jongpie jongpie temporarily deployed to Test October 6, 2021 07:51 Inactive
@jongpie jongpie temporarily deployed to Test October 6, 2021 07:53 Inactive
@jongpie jongpie temporarily deployed to Test October 6, 2021 07:53 Inactive
@jongpie jongpie temporarily deployed to Test October 6, 2021 08:03 Inactive
@jongpie jongpie temporarily deployed to Test October 6, 2021 08:07 Inactive
@jongpie jongpie temporarily deployed to Test October 6, 2021 08:11 Inactive
@jongpie jongpie temporarily deployed to Test October 6, 2021 08:11 Inactive
@jongpie jongpie temporarily deployed to Test October 6, 2021 08:19 Inactive
@fentes
Copy link

fentes commented Oct 6, 2021

@jongpie Thank you very much for implementing this feature into the main framework. This will really help to keep the overview of all Logs and let us easily find the wanted log.
I skimmed through the code changed and it looks good. Happy to test this in our org.

@jongpie
Copy link
Owner Author

jongpie commented Oct 6, 2021

@fentes, here is a beta version of the new v4.6.10 package that you can install to test out the changes - https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015krXQAQ

  • Since it's a beta version, you will only be able to install it into a sandbox right now. You won't be able to install it into production until I finish merging this pull request.
  • Before installing this version, you will have to comment-out any code that calls your custom method Logger.saveLog(String) since that will be removed when you install the package.
  • After installing this version, you can call Logger.setScenario(String) in your code to set the new scenario field.

Let me know if you have any feedback!

@jongpie jongpie temporarily deployed to Test October 6, 2021 15:22 Inactive
@jongpie jongpie temporarily deployed to Test October 6, 2021 15:25 Inactive
@jongpie jongpie temporarily deployed to Test October 6, 2021 15:25 Inactive
@jongpie jongpie temporarily deployed to Test October 12, 2021 05:27 Inactive
@jongpie jongpie added the Layer: Configuration Items related to the custom hierarchy setting LoggerSettings__c or any included custom metadata type label Oct 12, 2021
I quickly got tired of creating new button images for each release (to include the v number), and there previously weren't any install links for sandboxes
@jongpie jongpie temporarily deployed to Test October 14, 2021 03:02 Inactive
@jongpie jongpie temporarily deployed to Test October 14, 2021 03:06 Inactive
@jongpie jongpie temporarily deployed to Test October 14, 2021 03:06 Inactive
@jongpie jongpie temporarily deployed to Test October 14, 2021 03:16 Inactive
@jongpie jongpie temporarily deployed to Test October 14, 2021 03:32 Inactive
@jongpie jongpie temporarily deployed to Test October 14, 2021 03:36 Inactive
@jongpie jongpie temporarily deployed to Test October 14, 2021 03:36 Inactive
@jongpie jongpie temporarily deployed to Test October 14, 2021 03:46 Inactive
Copy link
Collaborator

@jamessimone jamessimone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few questions but in general this looks great!

@jongpie jongpie temporarily deployed to Test October 14, 2021 04:09 Inactive
@jongpie jongpie temporarily deployed to Test October 14, 2021 04:13 Inactive
@jongpie jongpie temporarily deployed to Test October 14, 2021 04:13 Inactive
@jongpie
Copy link
Owner Author

jongpie commented Oct 14, 2021

@jamessimone thanks for reviewing this!

@jongpie jongpie temporarily deployed to Test October 14, 2021 04:23 Inactive
@jongpie jongpie merged commit 6637526 into main Oct 14, 2021
@jongpie jongpie deleted the feature/log-scenario branch October 14, 2021 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layer: Configuration Items related to the custom hierarchy setting LoggerSettings__c or any included custom metadata type Layer: Log Management Items related to the custom objects & Logger Console app Layer: Logger Engine Items related to the core logging engine Logging Source: Apex Items related to using Logger within Apex Logging Source: Flow Items related to using Nebula Logger within Flow Logging Source: Lightning Components Items related to using Nebula Logger using JavaScript within lightning components (lwc & aura) Type: Enhancement New feature or request
Projects
None yet
4 participants