Skip to content

More Controls for Scenario-Based Logging

Compare
Choose a tag to compare
@jongpie jongpie released this 22 Sep 20:57
· 100 commits to main since this release
bade266

⚠️ For orgs that are upgrading to this version & that use scenario-based logging functionality: This release deprecates/renames 1 object & 1 field,so you may need to update some configurations in your org to use the new metadata:

  • The field LoggerSettings__c.DefaultLogScenario__c has been renamed to LoggerSettings__c.DefaultScenario__c, which is treated as a "new" field when upgrading. Existing LoggerSettings__c records in your org may need to be updated to move data in LoggerSettings__c.DefaultLogScenario__c to LoggerSettings__c.DefaultScenario__c. The original field LoggerSettings__c.DefaultScenario__c is now deprecated & will no longer be used.
  • The object LogScenarioRule__mdt has been renamed to LoggerScenarioRule__mdt, which is treated as a "new" object when upgrading. You will need to migrate any custom metadata records from LogScenarioRule__mdt to the new object LoggerScenarioRule__mdt. The original object LogScenarioRule__mdt is now deprecated & will no longer be used.

Core Package Changes

This release is complements some of the changes released in v4.8.1, and closes #355 by further enhancing scenario-based logging

  • Added new method Logger.endScenario(String scenario) suggested by @jamessimone. This provides a way for Apex developers to explicitly end a scenario, which then automatically rolls back to the previous scenario when applicable (and re-applies the previous scenario rule, if one exists)
  • Added new fields LogEntryEvent__e.EntryScenario__c and LogEntry__c.EntryScenario__c (used in addition to LogEntryEvent__e.TransactionScenario__c and Log__c.TransactionScenario__c). If multiple scenarios are specified during a transaction, the EntryScenario__c fields will indicate the specific scenario that was active when an entry was created. Another fantastic suggestion from @jamessimone
  • Deprecated LogScenarioRule__mdt object, replaced it with new object LoggerScenarioRule__mdt. This, combined with Logger.endScenario(), closes #347 (reported by @mikesobczak)
    • Using LoggerScenarioRule__mdt, some/all fields on LoggerSettings__c can be optionally overridden, allowing more control for different modules/groupings of code with an org

    • Using the optional StartTime__c and EndTime__c datetime fields, you can control when a LoggerScenarioRule__mdt should be used. This can be useful in situations where you need to temporarily override some LoggerSettings__c for your scenario

    • LogScenarioRule__mdt Deprecated Object:

      image

    • LoggerScenarioRule__mdt Revamped Object:

      image

  • Fixed #360 (reported by @NX-Mirco-Centrone) by changing Logger.logDatabaseErrors() overloads to always return a non-null instance of LogEntryEventBuilder
  • Updated backend code for LWC relatedLogEntries to remove a poorly-written & non-functioning Apex method that was trying determine the correct tab icon for the LogEntry__c object. Hardcoding the icon name into the LWC is simpler, uses less resources, and actually functions 😅

Slack Plugin Package Changes

  • Small cosmetic change in the messages posted to Slack - the fields LogEntry__c.StackTrace__c and LogEntry__c.ExceptionStackTrace__c have been updated to be formatted as code blocks, instead of inline code snippets. This works better in Slack's UI when the fields contain line breaks.
  • Created new package version v1.5.0 (making a somewhat arbitrary jump from v0.10.0, the old version numbers didn't align with the fact that the Slack plugin is production-ready)

Other Changes

  • Fixed #363 (reported by @fehays) by correcting some references in the migration script scripts/data/migrate-log-scenario-field-to-logger-scenario-object.apex
  • Removed build numbers from all package versions listed in sfdx-project.json - the updated version numbers are now consistent with the version number tags published in GitHub