Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save michael-adam-sheehan/a2a791bb555d61ae6e9af41e44fb6479 to your computer and use it in GitHub Desktop.
Save michael-adam-sheehan/a2a791bb555d61ae6e9af41e44fb6479 to your computer and use it in GitHub Desktop.
SFDC Errorlog Extract TraceFlag
# initial traceflag setting
body = {
'StartDate': f"{startDate}",
'ExpirationDate': f"{expiryDate}",
'ApexCode': 'FINEST',
'ApexProfiling': 'FINEST',
'Callout': 'FINEST',
'Database': 'FINEST',
'DebugLevelId': debugLevelId,
'System': 'FINE',
'TracedEntityId': tracedEntityId,
'Validation': 'INFO',
'Visualforce': 'FINER',
'Workflow': 'FINER',
'LogType': 'USER_DEBUG'
}
traceDebugUrl = f"{self._auth['instanceUrl']}/services/data/v{apiVersion}/tooling/sobjects/TraceFlag"
# patch already existing traceflag
if traceDebugId:
print(f"TraceDebugId defined setting body to expiration date only.")
body = {'StartDate': f"{startDate}",'ExpirationDate': f"{expiryDate}"}
traceDebugUrl += f"/{traceDebugId}"
traceDebugResponse = self._client.request('PATCH', traceDebugUrl, json=body, headers={
'Content-Type': 'application/json'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment