Apex BOOST Library
v1.7 from Lucidware Solutions (LWS)

Logger

global inherited sharing class Logger
DescriptionThe Logger's primary responsibility is to create Log (aBoost__Log__c) records. It utilizes immediate Platform Events to circumvent rollbacks that happen when an exception is thrown in a transaction. After calling Logger.log, you can be assured that the log record will be committed. In addition to the parameters you pass to a Logger.log method, Apex BOOST will record the context (class, method, line), current user, and stack trace.

In addition to the logging calls you add to your Apex code, logs will be auto-generated (no Apex code changes required) in the following scenarios:

  1. an exception is not caught in a Database.Batchable class that implements Database.RaisesPlatformEvents
  2. a fault is not caught in a screen flow

An additional benefit of Logger is that it can be turned on and off via hierarchical Apex BOOST custom settings. Just adjust the Log Level for any user or profile - even in production - to start creating log records in order to triage problems.

Finally, once you've implemented logging, stakeholders will be able to build reports and workflow to visualize and be notified of errors occurring in the system.

Usage:
 public class MyClass {
   public void myMethod() {
     // ERROR|scox~ MyClass.myMethod:4 simple test
     aBoost.Logger.log('simple test');

     // WARN|scox~ MyClass.myMethod:7 warning test
     aBoost.Logger.log(LoggingLevel.WARN, 'warning test');
   }
 }
 

For more information on logging with Apex BOOST, check out our blog post.

Methods

  log

  log

  log

  log

  log

Logger.Cleaner

global without sharing class Cleaner extends BatchJob.Handler
DescriptionA batch process that deletes old log records. On initial installation of Apex BOOST, this process is scheduled to run at 1am every day. The Log Days To Keep custom label specifies how many days log records will be kept. The default is DEFAULT_DAYS_TO_KEEP.

Any exceptions thrown by Logger.Cleaner will be logged by Logger.

Usage:
 // schedule the job to run every day at 1am
 System.schedule('Apex BOOST Log Cleaner', '0 0 1 * * ?',
   new aBoost.BatchJob(new aBoost.Logger.Cleaner()));

 // clean old logs immediately
 new aBoost.Logger.Cleaner().run();