Return save details when calling saveLog() methods
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> saveResultsback 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
RESTsavemode". I was able to reproduce the error. This occurred when ever I invokeparseStackTrace. The error somehow disappeared, after I renamed my apex method name forREST POSTwhere 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
parseStackTracecombined withSYNCHRONOUS_DML, I received error inYou 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 https://github.com/jongpie/NebulaLogger/discussions/234#discussioncomment-1552908