Skip to content

Bugfix for setting parent log transaction IDs, new Async Failures Additions plugin

Compare
Choose a tag to compare
@jongpie jongpie released this 10 May 21:29
· 111 commits to main since this release
7c6f49c

Core Package Changes

  • Fixed #300 by adding a new field Log__c.ParentLogTransactionId__c and updated trigger handler logic to optionally set Log__c.ParentLog__c when the parent log is found (or skips it when the parent log is not found)
    • The Log__c flexipage and page layout now use a new formula field Log__c.ParentLogLink__c to display either a link to ParentLog__c when set or the text value of ParentLogTransactionId__c
  • Updated the description of perm set LoggerLogCreator to indicate that it's currently optional, but might be needed in the future
  • Optimized LogEntryEventHandler.TAG_ASSIGNMENT_RULES by adding lazy-loading (discussed in #303) and adding a check on LogEntryTagRule__mdt.getAll().isEmpty() == true to minimize the usage of querying on LogEntryTagRule__mdt
  • Cleaned up some methods in Logger_Tests, and added TODOs for several test methods that will eventually be rewritten in a future release
  • Removed some stale @SuppressWarnings annotations in a couple of Apex classes-
  • Promoted a few buried strings within Apex classes to be constants, and a cleaned up a few other small code bits
  • Removed overload for LoggerMockDataCreator.createAggregateResult(Map<String, Object>) since the current mocking approach doesn't/can't actually set any fields on the mock AggregateResult
  • Added new text field LoggerSObjectHandler__mdt.SObjectTypeOverride__c as a way to support triggers on objects that are not supported via EntityDefinition lookups
  • Fixed #308 by adding the Schema namespace to a reference of FieldSetMember (now Schema.FieldSetMember)
  • Further fixed issues like #308 by adding empty classes with problematic names (FieldSet, FieldSetMember, SObjectField, SObjectType and Test for now) - this will cause deployment errors in the pipeline if there are any references that don't use the System/Schema namespaces

New Async Failures Additions Plugin

@jamessimone created a new plugin (implemented in #309), this plugin adds support for logging asynchronous batchable and queueable exceptions.

Batchable Error Logging

All a batch class needs to do is implement the marker Database.RaisesPlatformEvents interface and create a LoggerParameter__mdt record where the Value field matches the name of the batch class you are looking to add logging for, and the DeveloperName (the "Name" field) starts with BatchError:

// the class MUST implement Database.RaisesPlatformEvents for this to work correctly!
public class MyExampleBatchable implements Database.Batchable<SObject>, Database.RaisesPlatformEvents {
    // etc ...
}

And the CMDT record:

image

Once you've correctly configured those two things (the marker interface Database.RaisesPlatformEvents on the Apex batchable class, and the Logger Parameter CMDT record), your class will now log any uncaught exceptions that cause that batch class to fail unexpectedly.

Queueable Error Logging

If you have Apex classes that implement System.Queueable, you can add error logging with some minimal code additions:

public class MyExampleQueueable implements System.Queueable {
    public void execute (System.QueueableContext qc) {
        System.attachFinalizer(new LogFinalizer());
    }
}

If you'd like to do additional processing, you can alternatively choose to extend LogFinalizer:

public class MyCustomFinalizer extends LogFinalizer {
    protected override void innerExecute(System.FinalizerContext fc) {
        // do whatever you'd like!
        // errors will be logged automatically in addition to what you choose to do here
        // no need to call Logger.saveLog() manually on this code path
    }
}

Promoted All Plugin Packages

Previously, the package plugins had not been promoted, which prevented them from being installed directly into production. The most recent package versions for each plugin has now been promoted, allowing all plugins to now be installed into production. At the moment, there are 5 plugins available:

  • Async Logging Additions plugin (brand new, see above)
  • Big Object Archiving plugin
  • Log Retention Rules plugin
  • Logger Admin Dashboard plugin
  • Slack plugin

Note that several plugins are still considered to be in beta - the code has been tested and everything is expected to work in production, but as some plugins are relatively new, there may be some bigger changes between releases (depending on community feedback about new features & bugfixes).

Pipeline Changes

  • Added CODEOWNERS file
  • Changed build.yml so that the managed package build is a dependency for creating the unlocked package. This will add more time to the build, but it will ensure that the managed package (the more problematic package) can be created before creating the unlocked package
  • Fixed some broken images in some plugin README.md
  • Fixed some dependabot alerts by adding specific versions of some packages as dependencies in package.json & recreating package-lock.json