You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Added the ability to set & map custom fields, using a new CMDT LoggerFieldMapping__mdt and new LogEntryEventBuilder instance method overloads setField(Schema.SObjectField field, Object fieldValue) and
setField(Map<Schema.SObjectField, Object> fieldToValue)
* Added some CMDT records to the extra-tests directory that map the included custom fields (also stored in the extra-tests directory). These CMDT records are just to help with functionally/manually testing in a scratch org - they won't be included in any of the packages
* Scope creep: Updated several config classes to consistently have test-visible private methods before non-test-visible private methods
* Updated README.md to add details about custom field mappings, and cleaned up/updated some other README contents
* Added .github/FUNDING.yml so the repo has a sponsor button
The most robust logger for Salesforce. Works with Apex, Lightning Components, Flow, Process Builder & Integrations. Designed for Salesforce admins, developers & architects.
7
7
8
-
## Unlocked Package - v4.13.13
8
+
## Unlocked Package - v4.13.14
9
9
10
-
[](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oDsQAI)
11
-
[](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oDsQAI)
10
+
[](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oE2QAI)
11
+
[](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oE2QAI)
@@ -31,7 +31,7 @@ The most robust logger for Salesforce. Works with Apex, Lightning Components, Fl
31
31
32
32
## Features
33
33
34
-
1. Easily add log entries via Apex, Lightning Components (lwc & aura), Flow & Process Builder to generate 1 consolidated, unified log
34
+
1. Easily add log entries via Apex, Lightning Components (lightning web components (LWCs) & aura components), Flow & Process Builder to generate 1 consolidated, unified log
35
35
2. Manage & report on logging data using the `Log__c` and `LogEntry__c` objects
36
36
3. Leverage `LogEntryEvent__e` platform events for real-time monitoring & integrations
37
37
4. Enable logging and set the logging level for different users & profiles using `LoggerSettings__c` custom hierarchy setting
@@ -86,11 +86,6 @@ Nebula Logger is available as both an unlocked package and a managed package. Th
86
86
<td><code>System.debug()</code> is automatically called - the output can be configured with <code>LoggerSettings__c.SystemLogMessageFormat__c</code> to use any field on <code>LogEntryEvent__e</code></td>
87
87
<td>Requires adding your own calls for <code>System.debug()</code> due to Salesforce limitations with managed packages</td>
88
88
</tr>
89
-
<tr>
90
-
<td>Apex Stack Traces</td>
91
-
<td>Automatically stored in <code>LogEntry__c.StackTrace__c</code> when calling methods like <code>Logger.debug('my message');</code></td>
92
-
<td>Requires calling <code>parseStackTrace()</code> due to Salesforce limitations with managed packages. For example:<br><code>Logger.debug('my message').parseStackTrace(new DmlException().getStackTrace());</code></td>
93
-
</tr>
94
89
<tr>
95
90
<td>Logger Plugin Framework</td>
96
91
<td>Leverage Apex or Flow to build your own "plugins" for Logger - easily add your own automation to the any of the included objects: <code>LogEntryEvent__e</code>, <code>Log__c</code>, <code>LogEntry__c</code>, <code>LogEntryTag__c</code> and <code>LoggerTag__c</code>. The logger system will then automatically run your plugins for each trigger event (BEFORE_INSERT, BEFORE_UPDATE, AFTER_INSERT, AFTER_UPDATE, and so on).</td>
@@ -142,20 +137,21 @@ This results in 1 `Log__c` record with several related `LogEntry__c` records.
142
137
143
138
### Logger for Lightning Components: Quick Start
144
139
145
-
For lightning component developers, the `logger`lwc provides very similar functionality that is offered in Apex. Simply embed the `logger`lwc in your component, and call the desired logging methods within your code.
140
+
For lightning component developers, the `logger`LWC provides very similar functionality that is offered in Apex. Simply incorporate the `logger`LWC into your component, and call the desired logging methods within your code.
146
141
147
142
```javascript
148
-
// For lwc, retrieve logger from your component's template
@@ -388,7 +384,7 @@ For more details, check out the `LogMessage` class [documentation](https://jongp
388
384
389
385
## FeaturesforLightningComponentDevelopers
390
386
391
-
For lightning component developers, the included `logger` lwc can be used in other lwc& aura components for frontend logging. Similar to `Logger` and `LogEntryBuilder` Apex classes, the lwc has both `logger` and `logEntryBuilder` classes. This provides a fluent APIforjavascript developers so they can chain the method calls.
387
+
For lightning component developers, the included `logger` LWC can be used in other LWCs& aura components for frontend logging. Similar to `Logger` and `LogEntryBuilder` Apex classes, the LWC has both `logger` and `logEntryBuilder` classes. This provides a fluent APIforJavaScript developers so they can chain the method calls.
392
388
393
389
Once you've incorporated `logger` into your lightning components, you can see your `LogEntry__c` records using the included list view "All Component Log Entries'.
394
390
@@ -400,34 +396,48 @@ Each `LogEntry__c` record automatically stores the component's type ('Aura' or '
400
396
401
397
#### Example LWC Usage
402
398
403
-
To use the loggercomponent, it has to be added to your lwc's markup:
399
+
For lightning component developers, the `logger` LWC provides very similar functionality that is offered in Apex. Simply import the `logger` LWC in your component, and call the desired logging methods within your code.
404
400
405
-
```html
406
-
<template>
407
-
<c-logger></c-logger>
401
+
```javascript
402
+
// For LWC, import logger's createLogger() function into your component
logger.error('Hello, world!').addTag('some important tag');
423
-
logger.warn('Hello, world!');
424
-
logger.info('Hello, world!');
425
-
logger.debug('Hello, world!');
426
-
logger.fine('Hello, world!');
427
-
logger.finer('Hello, world!');
428
-
logger.finest('Hello, world!');
417
+
this.logger.error('Add log entry using Nebula Logger with logging level == ERROR').addTag('some important tag');
418
+
this.logger.warn('Add log entry using Nebula Logger with logging level == WARN');
419
+
this.logger.info('Add log entry using Nebula Logger with logging level == INFO');
420
+
this.logger.debug('Add log entry using Nebula Logger with logging level == DEBUG');
421
+
this.logger.fine('Add log entry using Nebula Logger with logging level == FINE');
422
+
this.logger.finer('Add log entry using Nebula Logger with logging level == FINER');
423
+
this.logger.finest('Add log entry using Nebula Logger with logging level == FINEST');
424
+
425
+
this.logger.saveLog();
426
+
}
429
427
430
-
logger.saveLog();
428
+
doSomething(event) {
429
+
this.logger.finest('Starting doSomething() with event: '+JSON.stringify(event));
430
+
try {
431
+
this.logger.debug('TODO - finishing implementation of doSomething()').addTag('another tag');
432
+
// TODO add the function's implementation below
433
+
} catch (thrownError) {
434
+
this.logger
435
+
.error('An unexpected error log entry using Nebula Logger with logging level == ERROR')
436
+
.setError(thrownError)
437
+
.addTag('some important tag');
438
+
} finally {
439
+
this.logger.saveLog();
440
+
}
431
441
}
432
442
}
433
443
```
@@ -584,6 +594,53 @@ Once you've implementing log entry tagging within Apex or Flow, you can choose h
584
594
585
595
---
586
596
597
+
## Adding Custom Fields to Nebula Logger's DataModel
598
+
599
+
As of `v4.13.14`, NebulaLogger supports defining, setting, and mapping custom fields within NebulaLogger's data model. This is helpful in orgs that want to extend Nebula Logger's included data model by creating their own org/project-specific fields.
600
+
601
+
This feature requires that you populate your custom fields yourself, and is only available in Apex currently. The plan is to add in a future release the ability to also set custom fields via JavaScript&Flow.
602
+
603
+
### AddingCustomFields to the PlatformEvent `LogEntryEvent__e`
604
+
605
+
The first step is to add a field to the platform event `LogEntryEvent__e`
606
+
607
+
-Create a custom field on `LogEntryEvent__e`.Any data type supported by platform events can be used.
608
+
609
+
-Inthis example, a custom text field called `SomeCustomField__c` has been added:
610
+
611
+

612
+
613
+
-Populate your field(s) in Apex by calling the instance method overloads `LogEntryEventBuilder.setField(Schema.SObjectField field, Object fieldValue)` or `LogEntryEventBuilder.setField(Map<Schema.SObjectField, Object> fieldToValue)`
614
+
615
+
```apex
616
+
Logger.info('hello, world')
617
+
// Set a single field
618
+
.setField(LogEntryEvent__e.SomeCustomTextField__c, 'some text value')
619
+
// Set multiple fields
620
+
.setFields(new Map<Schema.SObjectField, Object>{
621
+
LogEntryEvent__e.AnotherCustomTextField__c=>'another text value',
### AddingCustomFields to the CustomObjects `Log__c`, `LogEntry__c`, and `LoggerScenario__c`
627
+
628
+
If you want to store the data in one of NebulaLogger's custom objects, you can follow the above steps, and also...
629
+
630
+
- Create an equivalent custom field on one of Nebula Logger's custom objects - right now, only `Log__c`, `LogEntry__c`, and `LoggerScenario__c` are supported.
631
+
632
+
-Inthis example, a custom text field _also_ called `SomeCustomField__c` has been added to `Log__c` object -this will be used to store the value of the field `LogEntryEvent__e.SomeCustomField__c`:
633
+
634
+

635
+
636
+
- Create a record in the new CMDT `LoggerFieldMapping__mdt` to map the `LogEntryEvent__e` custom field to the custom object's custom field, shown below. Nebula Logger will automatically populate the custom object's target field with the value of the source `LogEntryEvent__e` field.
637
+
638
+
- In this example, a custom text field called `SomeCustomField__c` has been added to both `LogEntryEvent__e` and `Log__c`.
639
+
640
+

0 commit comments