Custom Logger Issue
Hello everyone,
I am having issues with my custom logger
When I add logger to trigger handler and Queable not able to detect logs.
My code for Trigger Handler
public without sharing class ContactTriggerHandler {
public void afterInsert(List<Contact> newContacts) {
CustomLogger.log(
CustomLogger.LogLevel.DEBUG,
'afterInsert handler invoked. Total incoming contacts: ' + newContacts.size(),
null,
null,
'ContactTriggerHandler'
);
List<Contact> contactsWithEmail = new List<Contact>();
for (Contact c : newContacts) {
if (String.isNotBlank(c.Email)) {
contactsWithEmail.add(c);
}
}
if (!contactsWithEmail.isEmpty()) {
System.enqueueJob(new StripeCustomerQueueable(contactsWithEmail));
}
}
}
==============
Queable Class
public without sharing class StripeCustomerQueueable implements Queueable, Database.AllowsCallouts {
private Set<Id> contactIds;
public StripeCustomerQueueable(List<Contact> contacts) {
this.contactIds = new Map<Id, Contact>(contacts).keySet();
CustomLogger.log(
CustomLogger.LogLevel.DEBUG,
'Queueable created. Contact IDs = ' + this.contactIds.size(),
null,
null,
'StripeCustomerQueueable'
);
}
public void execute(QueueableContext context) {
CustomLogger.log(
CustomLogger.LogLevel.INFO,
'StripeCustomerQueueable execution started.',
null,
null,
'StripeCustomerQueueable'
);
List<Contact> contactsFromDb = [
SELECT Id, FirstName, LastName, Email, Phone, Description
FROM Contact
WHERE Id IN :contactIds
];
CustomLogger.log(
CustomLogger.LogLevel.DEBUG,
'Fetched ' + contactsFromDb.size() + ' contacts from DB.',
null,
null,
'StripeCustomerQueueable'
);
List<Contact> contactsToUpdate = new List<Contact>();
StripeCallout stripeCallout = new StripeCallout();
for (Contact c : contactsFromDb) {
try {
String stripeCustomerId = stripeCallout.createCustomer(c);
if (String.isNotBlank(stripeCustomerId)) {
contactsToUpdate.add(new Contact(
Id = c.Id,
Stripe_Customer_Id__c = stripeCustomerId
));
CustomLogger.log(
CustomLogger.LogLevel.INFO,
'Stripe customer created for Contact ' + c.Id +
' → Stripe ID: ' + stripeCustomerId,
c.Id,
null,
'StripeCustomerQueueable'
);
}
} catch (Exception e) {
CustomLogger.log(
CustomLogger.LogLevel.ERROR,
'Stripe callout failed for Contact ' + c.Id + ' : ' + e.getMessage(),
c.Id,
e.getStackTraceString(),
'StripeCustomerQueueable'
);
}
}
if (!contactsToUpdate.isEmpty()) {
update contactsToUpdate;
CustomLogger.log(
CustomLogger.LogLevel.INFO,
'Updated ' + contactsToUpdate.size() + ' contacts with Stripe Customer IDs.',
null,
null,
'StripeCustomerQueueable'
);
}
}
}
The job runs fine,and gets completed.but in the logs I am not seeing the logs.Any help would be much appreciated.Thank you!
1
1 comment
Fahmeeda Begum
2
Custom Logger Issue
Integration Mastery Cohort
skool.com/integration-mastery-cohort-4062
Learn Integrations in 8 weeks.
Leaderboard (30-day)
Powered by