Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return save details when calling saveLog() methods #242

Open
jongpie opened this issue Nov 1, 2021 · 0 comments
Open

Return save details when calling saveLog() methods #242

jongpie opened this issue Nov 1, 2021 · 0 comments
Labels
Layer: Logger Engine Items related to the core logging engine Logging Source: Apex Items related to using Logger within Apex Logging Source: Flow Items related to using Nebula Logger within Flow Type: Enhancement New feature or request

Comments

@jongpie
Copy link
Owner

jongpie commented Nov 1, 2021

Currently, the method overloads Logger.saveLog() and Logger.saveLog(SaveMethod) do not return anything - @Soliton321 had a great suggestion to have the method return the save results so that orgs can implement their own error handling. I think it should return a new custom inner class (LoggerSaveResult or something similar) that includes relevant details for the save method (e.g., if using EVENT_BUS, it should include the List<Database.SaveResult> saveResults, if using QUEUEABLE, it should include the queueable job ID, and so on).

hey @jongpie thanks for suggestion. That helped me understand the logger more. We will take it into consideration to use unlocked package.

I've seen you have made error logging for platform even ab7dc20 Thank you for the effort. Could we expect to retrieve the List<Database.SaveResult> saveResults back in caller code in a future release? Since then it would be possible for user to perform their own error handling.

Regarding the error "log entries not saved using REST savemode". I was able to reproduce the error. This occurred when ever I invoke parseStackTrace. The error somehow disappeared, after I renamed my apex method name for REST POST where nebula logger is invoked. Otherwise error was silenced. Consumer of the exposed Apex REST webservice received success message. I even tried to made another insert in the next line as code below. Log will be created without logEntry, some fields like startTime, total CPU will be left empty. However, the account in the next line will be inserted.

Nebula.logger.info(payloadStr).parseStackTrace(new DmlException().getStackTraceString()); Nebula.Logger.saveLog(); insert Account(name='test');

Using parseStackTrace combined with SYNCHRONOUS_DML, I received error in You have uncommitted work pending. Please commit or rollback before calling out. Once again, this error disappeared after I renamed the method name where logging is invoked.

Hope this could help improve the error handling for the future.

Originally posted by @Soliton321 in #234 (reply in thread)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layer: Logger Engine Items related to the core logging engine Logging Source: Apex Items related to using Logger within Apex Logging Source: Flow Items related to using Nebula Logger within Flow Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant