Added the ability to capture HttpRequest headers
Resolved #701 by providing a way to indicate which HttpRequest
headers (and values) should be logged - previously, no header information was stored for HttpRequest
objects.
Conceptually, this is the same idea as logging headers when calling the other LogEntryBuilder
methods below:
setHttpResponseDetails(System.HttpResponse response)
setRestRequestDetails(System.RestRequest request)
setRestResponseDetails(System.RestResponse response)
However, there is one notable difference in the new behavior for logging HttpRequest
headers - the HttpRequest
class does not have a method to get all of the header keys, so you must explicitly tell Nebula Logger which header keys you want to log.
Core Unlocked Package Changes
- Added instance method overload
LogEntryEventBuilder.setHttpRequestDetails(System.HttpRequest request, List<String> headersToLog)
- Any header keys provided in
headersToLog
will now be logged - The existing overload,
setHttpRequestDetails(System.HttpRequest request)
, will not log any header information
- Any header keys provided in
- Added new
LogEntryEvent__e
fieldsHttpRequestHeaderKeys__c
andHttpRequestHeaders__c
to capture the specified list of header keys- The new fields mimic these existing fields:
HttpResponse
header data stored inHttpResponseHeaderKeys__c
andHttpResponseHeaders__c
RestRequest
header data stored inRestRequestHeaderKeys__c
andRestRequestHeaders__c
RestResponse
header data stored inRestResponseHeaderKeys__c
andRestRequestHeaders__c
- The new fields mimic these existing fields:
- Added new
LoggerParameter__mdt
recordStoreHttpRequestHeaderValues
to globally control ifHttpResponse
header values are stored when callingsetHttpRequestDetails(System.HttpRequest request, List<String> headersToLog)
- This new record mimics the existing record
StoreHttpResponseHeaderValues
(used for responses)
- This new record mimics the existing record
- Added new
LogEntry__c
fields to store theHttpRequest
header keys & values captured onLogEntryEvent__e
, as well as some checkbox fields to aid with filtering in SOQL, list views, etc.HttpRequestHeaderKeys__c
HasHttpRequestHeaderKeys__c
- set totrue
whenHttpRequestHeaderKeys__c
is not nullHttpRequestHeaders__c
HasHttpRequestHeaders__c
- set totrue
whenHttpRequestHeaders__c
is not null
- Updated the flexipage
LogEntryRecordPage
to add the 2 newLogEntry__c
fieldsHttpRequestHeaderKeys__c
andHttpRequestHeaders__c
- Both fields are conditionally displayed when populated, based on their corresponding checkbox fields
HasHttpRequestHeaderKeys__c
andHasHttpRequestHeaders__c
(respectively)
- Both fields are conditionally displayed when populated, based on their corresponding checkbox fields
- Updated the existing list view
AllHttpRequestLogEntries
to include the new fieldHttpRequestHeaderKeys__c
(HttpRequestHeader__c
is intentionally not included at this time)
Example
This example Apex script will create a LogEntry__c
record with data about the HttpRequest
- including the 2 specified header keys & their values.
System.HttpRequest httpRequest = new System.HttpRequest();
httpRequest.setBody('{ "hello": "world" }');
httpRequest.setEndpoint('https://fake.salesforce.com');
httpRequest.setHeader('some-header', 'some value');
httpRequest.setHeader('another-header', 'another value');
httpRequest.setMethod('GET');
List<String> headersToLog = new List<String>{ 'some-header', 'another-header' };
Logger.info('logging an HTTP request').setHttpRequestDetails(httpRequest, headersToLog);
Logger.saveLog();
Pipeline Changes
- Updated
build.yml
to fail the build if the codecov upload action fails
Installation Info
Core Unlocked Package - no namespace
Full Changelog: v4.14.7...v4.14.8
- SF CLI:
sf package install --wait 20 --security-type AdminsOnly --package 04t5Y0000015oS1QAI
- SFDX CLI:
sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y0000015oS1QAI
- Sandbox: https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oS1QAI
- Production: https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oS1QAI