Skip to content

Logger

An instance of the forvendi.BreezzApi.BreezzLogger class (accessible via forvendi.BreezzApi.LOGGER) enables logging of code execution warnings, errors, and performance execution metrics.

To minimize DML Governor Limits, BreezzLogger includes a built-in cache to hold logs during execution and persist them at the end of the transaction scope.

  • Methods prefixed with add append log entries to the in-memory cache (requiring a subsequent call to save() or publish()).
  • Methods prefixed with log execute immediate database DML operations and should not be used inside loops.

logError(className, methodName, message)

Logs an immediate error record to the database for the given class and method.

Signature:

public void logError(String className, String methodName, String message)

Parameters:

  • className: Name of the class where the error occurred.
  • methodName: Name of the method where the error occurred.
  • message: Text message describing the error.

Return Value: void

Usage Example:

forvendi.BreezzApi.LOGGER.logError('LoggerTest', 'executeProcess', 'Error Message: Something went wrong!');

logError(className, methodName, exc)

Logs an immediate error record for a caught Exception.

Signature:

public void logError(String className, String methodName, Exception exc)

Parameters:

  • className: Name of the class where the exception occurred.
  • methodName: Name of the method where the exception occurred.
  • exc: Exception instance caught during execution.

Return Value: void

Usage Example:

try {
    // Business logic
} catch (Exception e) {
    forvendi.BreezzApi.LOGGER.logError('AccountService', 'updateAccounts', e);
}

logError(className, methodName, result)

Logs an error record based on a database transaction result wrapper (forvendi.DB.DBResult).

Signature:

public forvendi.BreezzApi.BreezzLogger logError(String className, String methodName, forvendi.DB.DBResult result)

Parameters:

  • className: Name of the class where the error occurred.
  • methodName: Name of the method where the error occurred.
  • result: forvendi.DB.DBResult wrapping the Database operation result.

Return Value: forvendi.BreezzApi.BreezzLogger – The current logger instance.

Usage Example:

Account[] accts = new List<Account>{ new Account(Name='Account1'), new Account() };  
Database.SaveResult[] srList = Database.insert(accts, false);

forvendi.BreezzApi.LOGGER.logError('LoggerTest', 'bulkInsert', new forvendi.DB.DBResult(accts, srList));

addErrorLog(className, methodName, exc)

Adds an error log for a caught Exception to the in-memory cache.

Signature:

public forvendi.BreezzApi.BreezzLogger addErrorLog(String className, String methodName, Exception exc)

Parameters:

  • className: Name of the class where the exception occurred.
  • methodName: Name of the method where the exception occurred.
  • exc: Exception instance.

Return Value: forvendi.BreezzApi.BreezzLogger – The current logger instance.

Usage Example:

try {
    // Logic
} catch (Exception e) {
    forvendi.BreezzApi.LOGGER.addErrorLog('LoggerTest', 'process', e);
}
forvendi.BreezzApi.LOGGER.save();

addErrorLog(className, methodName, message)

Adds an error log message to the in-memory cache.

Signature:

public forvendi.BreezzApi.BreezzLogger addErrorLog(String className, String methodName, String message)

Parameters:

  • className: Name of the class where the error occurred.
  • methodName: Name of the method where the error occurred.
  • message: Error description message.

Return Value: forvendi.BreezzApi.BreezzLogger – The current logger instance.

Usage Example:

Object[] inputList = new Object[]{1, 2, '34', 23, 664, '12'};
Integer[] results = new Integer[]{};

for (Object input : inputList) {
    try {
        results.add((Integer) input);
    } catch (Exception e) {
        forvendi.BreezzApi.LOGGER.addErrorLog('Validator', 'getIntegers', input + ' -> ' + e.getMessage());
    }
}
forvendi.BreezzApi.LOGGER.save();

addErrorLog(className, methodName, result)

Adds a database operation error result to the in-memory log cache.

Signature:

public forvendi.BreezzApi.BreezzLogger addErrorLog(String className, String methodName, forvendi.DB.DBResult result)

Parameters:

  • className: Name of the class where the error occurred.
  • methodName: Name of the method where the error occurred.
  • result: forvendi.DB.DBResult instance.

Return Value: forvendi.BreezzApi.BreezzLogger – The current logger instance.


logWarnLog(className, methodName, message)

Logs an immediate warning log to the database.

Signature:

public forvendi.BreezzApi.BreezzLogger logWarnLog(String className, String methodName, String message)

Parameters:

  • className: Class name.
  • methodName: Method name.
  • message: Warning description.

Return Value: forvendi.BreezzApi.BreezzLogger – The current logger instance.


addWarnLog(className, methodName, message)

Adds a warning log entry to the in-memory cache.

Signature:

public forvendi.BreezzApi.BreezzLogger addWarnLog(String className, String methodName, String message)

Parameters:

  • className: Class name.
  • methodName: Method name.
  • message: Warning description.

Return Value: forvendi.BreezzApi.BreezzLogger – The current logger instance.


addTimeLog(className, methodName, metricName, timeInMS)

Adds execution duration metrics in milliseconds to the cache.

Signature:

public forvendi.BreezzApi.BreezzLogger addTimeLog(String className, String methodName, String metricName, Long timeInMS)

Parameters:

  • className: Class name.
  • methodName: Method name.
  • metricName: Name of the metric to track.
  • timeInMS: Execution duration in milliseconds.

Return Value: forvendi.BreezzApi.BreezzLogger – The current logger instance.

Usage Example:

Long startTime = Limits.getCpuTime();
// Executing logic
Long duration = Limits.getCpuTime() - startTime;

forvendi.BreezzApi.LOGGER.addTimeLog('LoggerTest', 'execute', 'ExecutionTime', duration);
forvendi.BreezzApi.LOGGER.save();

addTimeLog(className, methodName, metricName, timeInMS, details)

Adds execution duration metrics along with custom details to the cache.

Signature:

public forvendi.BreezzApi.BreezzLogger addTimeLog(String className, String methodName, String metricName, Long timeInMS, String details)

Parameters:

  • className: Class name.
  • methodName: Method name.
  • metricName: Name of the metric.
  • timeInMS: Duration in milliseconds.
  • details: Additional contextual details string.

Return Value: forvendi.BreezzApi.BreezzLogger – The current logger instance.


addMetricValue(processName, metricName, value)

Adds a generic numeric metric value for a specific process.

Signature:

public forvendi.BreezzApi.BreezzLogger addMetricValue(String processName, String metricName, Long value)

Parameters:

  • processName: Name of the process associated with the metric.
  • metricName: Name of the metric to track.
  • value: Numeric value.

Return Value: forvendi.BreezzApi.BreezzLogger – The current logger instance.

Usage Example:

forvendi.BreezzApi.LOGGER.addMetricValue('AccountBatch', 'DMLRowsUsed', Limits.getDmlRows());
forvendi.BreezzApi.LOGGER.save();

addNumberOfExecutionsMetric(processName)

Increments the execution counter metric for a specified process.

Signature:

public forvendi.BreezzApi.BreezzLogger addNumberOfExecutionsMetric(String processName)

Parameters:

  • processName: Name of the process.

Return Value: forvendi.BreezzApi.BreezzLogger – The current logger instance.


addNumberOfProcessedRecordsMetric(processName, val)

Tracks the count of records processed during a specific execution.

Signature:

public forvendi.BreezzApi.BreezzLogger addNumberOfProcessedRecordsMetric(String processName, Long val)

Parameters:

  • processName: Name of the process.
  • val: Number of records processed.

Return Value: forvendi.BreezzApi.BreezzLogger – The current logger instance.


publish()

Publishes all cached log entries and metrics via Platform Events or background handlers.

Signature:

public void publish()

Return Value: void


save()

Persists all cached error logs, warning logs, and metrics records to the database.

Signature:

public void save()

Return Value: void