New Log__c & LoggerSettings__c fields
LoggerSettings__c
custom hierarchy settings.
New field Log__c.Scenario__c
Closed #217 by adding a new field suggested by @fentes, 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
).
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.
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"
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.
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).
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'sSystem.debug()
when logging via Apex, Flow/Process Builder, or Lightning ComponentsIsComponentConsoleLoggingEnabled__c
- When enabled, Logger will automatically call the browser'sconsole.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
- Fixed #224 by adding an internal check in
Logger
forUserInfo.getSessionId() == null
to avoid an uncatchable error that can occur when callingSystem.Request.getCurrent()
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