Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save michael-adam-sheehan/66e7a32aae5b237e662a381c40aa44f3 to your computer and use it in GitHub Desktop.
Save michael-adam-sheehan/66e7a32aae5b237e662a381c40aa44f3 to your computer and use it in GitHub Desktop.
sfdc-errorlog-extraction-deletion
def delete(self):
print(f"Deleting logs from instance...")
if self.apexLogIds:
logIdsCsvFile = f"{self._logdir}/apex-logids.csv"
with open(logIdsCsvFile, 'w') as csvwriter_file:
csvwriter = csv.writer(csvwriter_file)
csvwriter.writerow(['Id'])
for id in self.apexLogIds:
csvwriter.writerow([id])
sfdxCmd = f"sfdx force:data:bulk:delete -s ApexLog -w 5 -f {logIdsCsvFile} --targetusername={self.targetusername}"
try:
p = subprocess.Popen(sfdxCmd, shell=True,
stdout=subprocess.PIPE, encoding='utf-8')
p.wait()
result = p.communicate()[0].strip()
p.stdout.close()
print(f"{result}")
except:
e = sys.exc_info()[0]
print(f"Error deleting logs: {e}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment