-
Notifications
You must be signed in to change notification settings - Fork 0
Plugin: Nebula Logger
This plugin leverages the Plugin Framework to automatically logs details about your DML and SOQL operations, via Nebula Logger.
Nebula Logger is a popular logging framework for Salesforce. Like Apex Database Layer, it's free, and open-source.
To use this plugin, you must have the most recent version of Apex Database Layer and Nebula Logger installed.
If you're using both the latest & unmanaged versions of Apex Database Layer and Nebula Logger installed, you may install this plugin as an unlocked package.
First, locate the latest version of the plugin package, called nebula-logger-plugin@latest in sfdx-project.json:
sf package install --package <<package_version_id>> --wait 10
⚠️ Note: If you are using a managed version of Apex Database Layer and/or Nebula Logger, you won't be able to formally install the package. Instead, manually copy the contents of these two Apex Classes in your desired environment:
Once installed, navigate to Setup > Custom Metadata > Database Layer Settings. If a record already exists, use that record. Else, create a new record, called "Default".
Set the Custom Metadata record's DML: Pre & Post Processor and SOQL: Pre & Post Processor fields to be the name of the Apex class: DatabaseLayerNebulaLoggerAdapter:
Note: Once configured, this custom metadata record won't be altered by upgrading the Apex Database Layer package, or the plugin package itself.
Whenever a DML or SOQL operation runs, the plugin will log the details of those operations to Nebula Logger. This results in log entries with the apex-database-layer Log Entry Tag.
Just before a DML operation is processed, the plugin will issue a FINEST log entry summarizing the action that's about to take place.
- The
Dml.Requestis serialized and shown in the message body - The records being operated on are shown in the
Related Recordstab
After a DML operation is processed, the plugin issues another FINEST log entry summarizing the action that took place.
- The
Dml.Requestis serialized and shown in the message body - The records that were operated on are shown in the
Related Recordstab - The relevant database result objects (ex.,
Database.SaveResult) are shown in theRelated Recordstab
If an exception is thrown during a DML operation, an ERROR log entry is issued:
- The
Exceptionmessage is shown in the message body - The
Dml.Requestis serialized and shown in the message body - The records that were operated on are shown in the
Related Recordstab
Just before a SOQL operation is processed, the plugin issues a FINEST log entry summarizing the query about to take place:
- The text of the query is available in the message body
After a SOQL operation is processed, the plugin issues another FINEST log entry summarizing the query and its results:
- The text of the query is available in the message body
- The resulting SObject records are available in the
Related Recordstab- Note: Other query operations (ex.,
getCursor,countQuery) that do not output SObjects will be printed in the message body instead
- Note: Other query operations (ex.,
If an exception is thrown during a SOQL operation, an ERROR log entry is issued:
- The text of the query is available in the message body
- The
Exceptionmessage is shown in the message body
Many MockSoql query operations use the query method as the basis for building mock results. This may result in additional logs being issued.
For example, MockSoql.getQueryLocator calls MockSoql.query to generate the list of records to be returned, and then wraps the results in a Soql.QueryLocator. In this scenario, the plugin issues 4 FINEST logs: one before/after MockSoql.getQueryLocator, and one before/after MockSoql.query.
- Generating Test Records
- Dml
- Soql
- Cmdt
- Plugins
- DatabaseLayer
- Dml
- MockDml
- MockRecord
- Cmdt
- MockCmdt
- MockSoql
-
Soql
- Soql.AggregateResult
- Soql.Aggregation
- Soql.Binder
- Soql.Builder
- Soql.Condition
- Soql.ConditionalLogic
- Soql.Criteria
- Soql.Cursor
- Soql.Function
- Soql.InnerQuery
- Soql.InvalidParameterValueException
- Soql.LogicType
- Soql.NullOrder
- Soql.Operation
- Soql.Operator
- Soql.ParentField
- Soql.PreAndPostProcessor
- Soql.QueryLocator
- Soql.Request
- Soql.Scope
- Soql.Selectable
- Soql.SortDirection
- Soql.SortOrder
- Soql.Subquery
- Soql.TypeOf
- Soql.Usage
- Soql.WhenClause