Skip to content

Commit f602f90

Browse files
authored
Added logging support for instances of RestRequest and RestResponse (#613)
* Added new fields & instance method LogEntryEventBuilder.setRestResponseDetails() to store info on instances of System.RestResponse * Added new fields & instance method LogEntryEventBuilder.setRestRequestDetails() to store info on instances of System.RestRequest * Added new flexipage sections 'Apex REST Service Request' and 'Apex REST Service Response' in LogEntryRecordPage that conditionally display the new fields for RestRequest and RestResponse * Renamed the existing flexipage sections 'HTTP Request' and 'HTTP Response' to 'HTTP Callout Request' and 'HTTP Callout Response' for clarity * Reduced the max length of several existing long textarea fields to conserve some usage of the per-object limit - previously, these fields were all using the max length of 131072, which is more than what's needed
1 parent 21e02ac commit f602f90

65 files changed

Lines changed: 1840 additions & 34 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
The most robust logger for Salesforce. Works with Apex, Lightning Components, Flow, Process Builder & Integrations. Designed for Salesforce admins, developers & architects.
77

8-
## Unlocked Package - v4.12.8
8+
## Unlocked Package - v4.12.9
99

10-
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk6cQAC)
11-
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk6cQAC)
10+
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk7BQAS)
11+
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk7BQAS)
1212
[![View Documentation](./images/btn-view-documentation.png)](https://jongpie.github.io/NebulaLogger/)
1313

14-
`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001Mk6cQAC`
14+
`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001Mk7BQAS`
1515

16-
`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001Mk6cQAC`
16+
`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001Mk7BQAS`
1717

1818
---
1919

docs/apex/Configuration/LoggerParameter.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ Indicates if Nebula Logger will send an error email notification if any internal
9898

9999
Indicates if Nebula Logger will store the header values when logging an instance of `System.HttpResponse`. Controlled by the custom metadata record `LoggerParameter.StoreHttpResponseHeaderValues`, or `true` as the default. Regardless of how this parameter is configured, Nebula Logger will still log the header keys of any instance of `System.HttpResponse` that is logged - this parameter only controls if the header values are stored.
100100

101+
#### `STORE_REST_REQUEST_HEADER_VALUES``Boolean`
102+
103+
Indicates if Nebula Logger will store the header values when logging an instance of `System.RestRequest`. Controlled by the custom metadata record `LoggerParameter.StoreRestRequestHeaderValues`, or `true` as the default. Regardless of how this parameter is configured, Nebula Logger will still log the header keys of any instance of `System.RestRequest` that is logged - this parameter only controls if the header values are stored.
104+
105+
#### `STORE_REST_RESPONSE_HEADER_VALUES``Boolean`
106+
107+
Indicates if Nebula Logger will store the header values when logging an instance of `System.RestResponse`. Controlled by the custom metadata record `LoggerParameter.StoreRestResponseHeaderValues`, or `true` as the default. Regardless of how this parameter is configured, Nebula Logger will still log the header keys of any instance of `System.RestResponse` that is logged - this parameter only controls if the header values are stored.
108+
101109
#### `SYSTEM_DEBUG_MESSAGE_FORMAT``String`
102110

103111
The merge-field syntax to use when calling System.debug(). Controlled by the custom metadata record `LoggerParameter.SystebugMessageFormat`, or `{OriginLocation__c}\n{Message__c}` as the default

docs/apex/Logger-Engine/LogEntryEventBuilder.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,46 @@ LogEntryEventBuilder
565565

566566
An instance of LogEntryEventBuilder with the given record.
567567

568+
#### `setRestRequestDetails(System.RestRequest request)``LogEntryEventBuilder`
569+
570+
Sets the log entry event's REST Request fields
571+
572+
##### Parameters
573+
574+
| Param | Description |
575+
| --------- | ------------------------------------ |
576+
| `request` | The instance of `RestRequest` to log |
577+
578+
##### Return
579+
580+
**Type**
581+
582+
LogEntryEventBuilder
583+
584+
**Description**
585+
586+
The same instance of `LogEntryEventBuilder`, useful for chaining methods
587+
588+
#### `setRestResponseDetails(System.RestResponse response)``LogEntryEventBuilder`
589+
590+
Sets the log entry event's REST Response fields
591+
592+
##### Parameters
593+
594+
| Param | Description |
595+
| ---------- | ------------------------------------- |
596+
| `response` | The instance of `RestResponse` to log |
597+
598+
##### Return
599+
600+
**Type**
601+
602+
LogEntryEventBuilder
603+
604+
**Description**
605+
606+
The same instance of `LogEntryEventBuilder`, useful for chaining methods
607+
568608
#### `setTopics(List<String> tags)``LogEntryEventBuilder`
569609

570610
Deprecated - use `addTags(List&lt;String&gt; tags)` instead. This method will be removed in a future release

nebula-logger/core/main/configuration/classes/LoggerParameter.cls

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,38 @@ public class LoggerParameter {
350350
private set;
351351
}
352352

353+
/**
354+
* @description Indicates if Nebula Logger will store the header values when logging an instance of `System.RestRequest`.
355+
* Controlled by the custom metadata record `LoggerParameter.StoreRestRequestHeaderValues`, or `true` as the default.
356+
* Regardless of how this parameter is configured, Nebula Logger will still log the header keys of any instance of
357+
* `System.RestRequest` that is logged - this parameter only controls if the header values are stored.
358+
*/
359+
public static final Boolean STORE_REST_REQUEST_HEADER_VALUES {
360+
get {
361+
if (STORE_REST_REQUEST_HEADER_VALUES == null) {
362+
STORE_REST_REQUEST_HEADER_VALUES = getBoolean('StoreRestRequestHeaderValues', true);
363+
}
364+
return STORE_REST_REQUEST_HEADER_VALUES;
365+
}
366+
private set;
367+
}
368+
369+
/**
370+
* @description Indicates if Nebula Logger will store the header values when logging an instance of `System.RestResponse`.
371+
* Controlled by the custom metadata record `LoggerParameter.StoreRestResponseHeaderValues`, or `true` as the default.
372+
* Regardless of how this parameter is configured, Nebula Logger will still log the header keys of any instance of
373+
* `System.RestResponse` that is logged - this parameter only controls if the header values are stored.
374+
*/
375+
public static final Boolean STORE_REST_RESPONSE_HEADER_VALUES {
376+
get {
377+
if (STORE_REST_RESPONSE_HEADER_VALUES == null) {
378+
STORE_REST_RESPONSE_HEADER_VALUES = getBoolean('StoreRestResponseHeaderValues', true);
379+
}
380+
return STORE_REST_RESPONSE_HEADER_VALUES;
381+
}
382+
private set;
383+
}
384+
353385
/**
354386
* @description The merge-field syntax to use when calling System.debug().
355387
* Controlled by the custom metadata record `LoggerParameter.SystemDebugMessageFormat`, or `{OriginLocation__c}\n{Message__c}` as the default

nebula-logger/core/main/configuration/customMetadata/LoggerParameter.StoreHttpResponseHeaderValues.md-meta.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
66
>
7-
<label>Store Http Response Header Values</label>
7+
<label>Store HTTP Response Header Values</label>
88
<protected>false</protected>
99
<values>
1010
<field>Description__c</field>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<CustomMetadata
3+
xmlns="http://soap.sforce.com/2006/04/metadata"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
6+
>
7+
<label>Store REST Request Header Values</label>
8+
<protected>false</protected>
9+
<values>
10+
<field>Description__c</field>
11+
<value
12+
xsi:type="xsd:string"
13+
>When set to &apos;true&apos; (default), Nebula Logger will store the header values of any instance of an RestRequest that is logged using the instance method LogEntryEventBuilder.setRestRequestDetails().
14+
15+
When set to &apos;false&apos;, the header values are not stored or referenced by Nebula Logger.
16+
17+
Regardless of how this parameter is configured, Nebula Logger will still log the header keys of any instance of an RestRequest that is logged - this parameter only controls if the header values are stored.</value>
18+
</values>
19+
<values>
20+
<field>Value__c</field>
21+
<value xsi:type="xsd:string">true</value>
22+
</values>
23+
</CustomMetadata>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<CustomMetadata
3+
xmlns="http://soap.sforce.com/2006/04/metadata"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
6+
>
7+
<label>Store REST Response Header Values</label>
8+
<protected>false</protected>
9+
<values>
10+
<field>Description__c</field>
11+
<value
12+
xsi:type="xsd:string"
13+
>When set to &apos;true&apos; (default), Nebula Logger will store the header values of any instance of an RestResponse that is logged using the instance method LogEntryEventBuilder.setRestResponseDetails().
14+
15+
When set to &apos;false&apos;, the header values are not stored or referenced by Nebula Logger.
16+
17+
Regardless of how this parameter is configured, Nebula Logger will still log the header keys of any instance of an RestResponse that is logged - this parameter only controls if the header values are stored.</value>
18+
</values>
19+
<values>
20+
<field>Value__c</field>
21+
<value xsi:type="xsd:string">true</value>
22+
</values>
23+
</CustomMetadata>

nebula-logger/core/main/log-management/classes/LogEntryEventHandler.cls

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,20 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler {
326326
RecordSObjectClassification__c = logEntryEvent.RecordSObjectClassification__c,
327327
RecordSObjectType__c = logEntryEvent.RecordSObjectType__c,
328328
RecordSObjectTypeNamespace__c = logEntryEvent.RecordSObjectTypeNamespace__c,
329+
RestRequestBody__c = logEntryEvent.RestRequestBody__c,
330+
RestRequestBodyMasked__c = logEntryEvent.RestRequestBodyMasked__c,
331+
RestRequestHeaderKeys__c = logEntryEvent.RestRequestHeaderKeys__c,
332+
RestRequestHeaders__c = logEntryEvent.RestRequestHeaders__c,
333+
RestRequestMethod__c = logEntryEvent.RestRequestMethod__c,
334+
RestRequestParameters__c = logEntryEvent.RestRequestParameters__c,
335+
RestRequestRemoteAddress__c = logEntryEvent.RestRequestRemoteAddress__c,
336+
RestRequestResourcePath__c = logEntryEvent.RestRequestResourcePath__c,
337+
RestRequestUri__c = logEntryEvent.RestRequestUri__c,
338+
RestResponseBody__c = logEntryEvent.RestResponseBody__c,
339+
RestResponseBodyMasked__c = logEntryEvent.RestResponseBodyMasked__c,
340+
RestResponseHeaderKeys__c = logEntryEvent.RestResponseHeaderKeys__c,
341+
RestResponseHeaders__c = logEntryEvent.RestResponseHeaders__c,
342+
RestResponseStatusCode__c = logEntryEvent.RestResponseStatusCode__c,
329343
StackTrace__c = logEntryEvent.StackTrace__c,
330344
Timestamp__c = timestamp,
331345
TransactionEntryNumber__c = logEntryEvent.TransactionEntryNumber__c,

nebula-logger/core/main/log-management/classes/LogEntryHandler.cls

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ public without sharing class LogEntryHandler extends LoggerSObjectHandler {
273273
logEntry.HasHttpResponseHeaders__c = logEntry.HttpResponseHeaders__c != null;
274274
logEntry.HasInlineTags__c = logEntry.Tags__c != null;
275275
logEntry.HasRecordJson__c = logEntry.RecordJson__c != null;
276+
logEntry.HasRestRequestBody__c = logEntry.RestRequestBody__c != null;
277+
logEntry.HasRestRequestHeaderKeys__c = logEntry.RestRequestHeaderKeys__c != null;
278+
logEntry.HasRestRequestHeaders__c = logEntry.RestRequestHeaders__c != null;
279+
logEntry.HasRestResponseBody__c = logEntry.RestResponseBody__c != null;
280+
logEntry.HasRestResponseHeaderKeys__c = logEntry.RestResponseHeaderKeys__c != null;
281+
logEntry.HasRestResponseHeaders__c = logEntry.RestResponseHeaders__c != null;
276282
logEntry.HasStackTrace__c = logEntry.StackTrace__c != null;
277283
}
278284
}

0 commit comments

Comments
 (0)