Plugin Framework
Extend Nebula Logger with your own Apex or Flow automation that runs automatically after trigger events.
If you want to add your own automation to the included custom objects, you can leverage Apex or Flow to define “plugins” - the logger system will then automatically run the plugins after each trigger event (BEFORE_INSERT, BEFORE_UPDATE, AFTER_INSERT, AFTER_UPDATE, and so on). Currently, these objects are supported:
LogEntryEvent__eplatform eventLog__ccustom objectLogEntry__ccustom objectLogEntryTag__ccustom objectLoggerTag__ccustom objectLoggerScenario__ccustom object
This framework (currently in beta) makes it easy to build your own plugins, or deploy/install others’ prebuilt packages, without having to modify the logging system directly.
Build a plugin
Your Flow should be built as an auto-launched Flow with these parameters:
InputparametertriggerOperationType- The name of the current trigger operation (such asBEFORE_INSERT,BEFORE_UPDATE, etc.)InputparametertriggerNew- The list of logger records being processed (Log__corLogEntry__crecords)OutputparameterupdatedTriggerNew- If your Flow makes any updates to the collection of records, you should return a record collection containing the updated recordsInputparametertriggerOld- The list of logger records as they exist in the database
// Implement LoggerPlugin.Triggerable:
public class ExampleTriggerablePlugin implements LoggerPlugin.Triggerable {
public void execute(LoggerPlugin__mdt configuration, LoggerTriggerableContext input) {
// Example: only run the plugin for Log__c records
if (context.sobjectType != Schema.Log__c.SObjectType) {
return;
}
List<Log__c> logs = (List<Log__c>) input.triggerNew;
switch on input.triggerOperationType {
when BEFORE_INSERT {
for (Log__c log : logs) {
log.Status__c = 'On Hold';
}
}
when BEFORE_UPDATE {
// TODO add before-update logic
}
}
}
}Configure the plugin
Once you’ve created your Apex or Flow plugin(s), you will also need to configure the plugin using custom metadata types:
| Metadata type | Purpose |
|---|---|
LoggerSObjectHandlerPlugin__mdt |
Defines your plugin, including the plugin type (Apex or Flow) and the API name of your plugin’s Apex class or Flow |
LoggerSObjectHandlerPluginParameter__mdt |
Defines any configurable parameters needed for your plugin, such as environment-specific URLs and other similar configurations |
Adapted from the Nebula Logger wiki, © Jonathan Gillespie and contributors, MIT License.