NebulaLogger icon indicating copy to clipboard operation
NebulaLogger copied to clipboard

Add a way to bypass/ignore additional Apex classes when calculating each entry's origin details

Open jongpie opened this issue 3 years ago • 0 comments

Discussed in https://github.com/jongpie/NebulaLogger/discussions/330

Originally posted by TKGC June 13, 2022 Is there a simple way in APEX to set the Origin__c value of a LogEntry__c record? I am considering the possibility of creating an abstract wrapper class (e.g. MyOrgLogHandler) to be utilized to handle logging operations within my org. In addition to decoupling, it could also abstract Logger.saveLog() from users.

For example: MyOrgLogHandler.logInfoMessage('message');

However, wrapping the Logger calls within a custom MyOrgLogHandler class will result in the LogEntry__c.Origin__c value being set to MyOrgLogHandler - and therefore not provide that added useful peice of information in the LogEntry details. Is there a way to override the Origin of the LogEntry record? (e.g. setting it to the last value parsed from the stack trace)

This may also open the possibility to abstract managing the Log__c.ParentLog__c to relate logs across transactions for a user session when applicable - I am still trying to figure out how to go about this for user session scenarios beyond Batchable and Queueable Jobs (which already have clear examples provided in the documentation). I would also be appreciative of any suggestions to this end.

Any thoughts or input is much appreciated. Thank you!

jongpie avatar Jun 23 '22 19:06 jongpie