Skip to content

Bugfix: Entry Save Override Is Not Always Used

Choose a tag to compare

@jongpie jongpie released this 03 Apr 16:11
· 9 commits to main since this release
ec2cfe8

Thanks again to @jvega-intakedesk & team for reporting issue #856 (via discussion #855), helping to test PR #857! 🥳

Core Unlocked Package Changes

Quick context on this release: in Apex, developers have the ability to force certain entries to always save, even if the entry's logging level doesn't meet the current user's logging level (e.g., a DEBUG entry can be made to always save, even if the user's logging level is set to INFO). This is useful for a lot of teams in a lot of situations (such as auditing/monitoring requirements), and has been a feature for a loooong time.

But, @jvega-intakedesk & team recently pointed out that although the LogEntryEvent__e platform events are successfully published, the corresponding LogEntry__c records are inadvertently not created. This release corrects this issue with a few changes:

  • Added new fields EntrySaveReason__c on LogEntryEvent__e & LogEntry__c to explicitly track why an entry is saved, with 2 possible values:

    1. Logging Level Met: indicates that the entry was saved because the entry's specified logging level meets the logging user's configured logging level settings, stored in LoggerSettings__c.LoggingLevel__c.
    2. Save Overridden: indicates that the entry was saved because a developer has overridden in code the shouldSave flag for the entry. This is done by developers to ensure certain entries are always logged, regardless of the user's configured logging level.
  • Updated LogEntryEventBuilder and LogEntryEventHandler to set the new fields on LogEntryEvent__e and LogEntry__c.

    • ℹ️ Going forward, all new LogEntryEvent__e and LogEntry__c records will now have a value populated in EntrySaveReason__c.
    • ⚠️ Existing LogEntry__c records will still have null - no changes are being introduced to backfill the data.
  • Updated the logic in LogEntryEventHandler.filterLogEntryEventsToSave() to check the value of the new field LogEntryEvent__e.EntrySaveReason__c. Any entries with a save reason of Override are always saved in LogEntry__c (which is the piece that directly fixes #856).

  • The flexipage LogEntryRecordPage has also been updated to display the new field LogEntry__c.EntrySaveReason__c when it's populated. For any existing LogEntry__c records with a null value, the flexipage will hide the field.

    image

    image

Installation Info

Core Unlocked Package - no namespace