Logger
An instance of the forvendi.BreezzApi.BreezzLogger class enables logging of code execution warnings and errors and gathering execution metrics. To minimize the number of DML operations, BreezzLogger includes a built-in cache to store logs during code execution and persist them at the end of the process. Methods prefixed with add append logs to the cache and require subsequent saving. Conversely, methods prefixed with log directly create logs in the database and should not be used within loops.
logError(String className, String methodName, String message)
Logs an error message for the given class and method with a given message.
Signature:
forvendi.BreezzApi.LOGGER.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 - error message
Return Value:
void
Usage:
forvendi.BreezzApi.LOGGER.logError('LoggerTest','Log','Error Message, this went wrong!');
logError(String className, String methodName, Exception exc)
Logs an error message for the given class and method with a given exception.
Signature:
forvendi.BreezzApi.LOGGER.logError(String className, String methodName, Exception exc);
Parameters:
- className - name of the class where the error occurred
- methodName - name of the method where the error occurred
- exc - exception that occurred
Return Value:
void
Usage:
public class BreezzException extends Exception {}
forvendi.BreezzApi.LOGGER.logError('LoggerTest','Log',new BreezzException());
logError(String className, String methodName, DB.DBResult result)
Logs an error message for the given class and method with a given DB result.
Signature:
forvendi.BreezzApi.LOGGER.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 - DB result that caused the error
Return Value:
The current BreezzLogger Instance.
Usage:
Account[] accts = new List<Account>{new Account(Name='Account1'), new Account()};
Database.SaveResult[] srList = Database.insert(accts, false);
forvendi.BreezzApi.LOGGER.logError('LoggerTest','Log',new forvendi.DB.DBResult(accts,srList));
addErrorLog(String className, String methodName, Exception exc)
Adds an error log for the given class and method with a given Exception.
Signature:
forvendi.BreezzApi.LOGGER.addErrorLog(String className, String methodName, Exception exc);
Parameters:
- className - name of the class where the error occurred
- methodName - name of the method where the error occurred
- exc - exception that occurred
Return Value:
The current BreezzLogger Instance.
Usage:
public class BreezzException extends Exception {}
forvendi.BreezzApi.LOGGER.addErrorLog('LoggerTest','Log',new BreezzException());
forvendi.BreezzApi.LOGGER.save();
addErrorLog(String className, String methodName, String message)
Adds an error log for the given class and method with a given message.
Signature:
forvendi.BreezzApi.LOGGER.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 - message which describes the error
Return Value:
The current BreezzLogger Instance.
Usage:
1Object[] inputList = new Object[]{1, 2, '34', 23, 664, '12'};
2Integer[] results = new Integer[]{};
3for (Object input : inputList) {
4 try {
5 Integer result = (Integer)input;
6 results.add(result);
7 } catch (Exception e) {
8 forvendi.BreezzApi.LOGGER.addErrorLog('Validator', 'getIntegers', input + ' → ' + e.getMessage());
9 }
10}
11forvendi.BreezzApi.LOGGER.save();
Above code is validating if inputList collection contains integers, for all invalid values the system will log an error. Error Logs are cached in the Logger cache and persisted in the forvendi__B_ErrorLog__c object at the end of the process.
addErrorLog(String className, String methodName, DB.DBResult result)
Adds an error log for the given class and method with a given DB result.
Signature:
forvendi.BreezzApi.LOGGER.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 - DB result that caused the error
Return Value:
The current BreezzLogger Instance.
Usage:
1Account[] accts = new List<Account>{
2 new Account(Name='Account1'),
3 new Account()};
4
5Database.SaveResult[] srList = Database.insert(accts, false);
6for (Database.SaveResult sr : srList) {
7 if(!sr.isSuccess()){
8 forvendi.BreezzApi.LOGGER.addErrorLog('LoggerTest','Log',new forvendi.DB.DBResult(accts,srList));
9 }
10}
11forvendi.BreezzApi.LOGGER.save();
logWarnLog(String className, String methodName, String message)
Logs a warning log for the given class and method name with the given message.
Signature:
forvendi.BreezzApi.LOGGER.logWarnLog(String className, String methodName, String message);
Parameters:
- className - name of the class where the warning occurred
- methodName - name of the method where the warning occurred
- message - message associated with the warning
Return Value:
The current BreezzLogger Instance.
Usage:
forvendi.BreezzApi.LOGGER.logWarnLog('LoggerTest','Log','Error Message, this went wrong!');
addWarnLog(String className, String methodName, String message)
Adds a warning log for the given class and method name with the given message.
Signature:
forvendi.BreezzApi.LOGGER.addWarnLog(String className, String methodName, String message);
Parameters:
- className - name of the class where the warning occurred
- methodName - name of the method where the warning occurred
- message - message associated with the warning
Return Value:
The current BreezzLogger Instance.
Usage:
1Object[] inputList = new Object[]{1, 2, '34', 23, 664, '12'};
2Integer[] results = new Integer[]{};
3for (Object input : inputList) {
4 try {
5 Integer result = (Integer)input;
6 results.add(result);
7 } catch (Exception e) {
8 forvendi.BreezzApi.LOGGER.addWarnLog('Validator', 'getIntegers', input + ' → ' + e.getMessage());
9 }
10}
11forvendi.BreezzApi.LOGGER.save();
Above code is validating if inputList collection contains integers, for all invalid values the system will log an error. Error Logs are cached in the Logger cache and persisted in the forvendi__B_Log__c object at the end of the process.
addTimeLog(String className, String methodName, String metricName, Long timeInMS)
Adds a time log for the given class and method name with the given metric name and time in milliseconds.
Signature:
forvendi.BreezzApi.LOGGER.addTimeLog(String className, String methodName, String metricName, Long timeInMS);
Parameters:
- className - name of the class where the time log occurred
- methodName - name of the method where the time log occurred
- metricName - name of the metric to be logged
- timeInMS - time in milliseconds to be logged
Return Value:
The current BreezzLogger Instance.
Usage:
forvendi.BreezzApi.LOGGER.addTimeLog('LoggerTest', 'Log', 'timeLogMetrics', 1200);
forvendi.BreezzApi.LOGGER.save();
Above code is adding a TimeLog into a metrics ald place in value label. Metrics are cached in the forvendi__B_Metric__c object at the end of the process.
addTimeLog(String className, String methodName, String metricName, Long timeInMS, String details)
Adds a time log for the given class and method name with the given metric name and time in milliseconds and details.
Signature:
forvendi.BreezzApi.LOGGER.addTimeLog(String className, String methodName, String metricName, Long timeInMS, String details);
Parameters:
- className - name of the class where the time log occurred
- methodName - name of the method where the time log occurred
- metricName - name of the metric to be logged
- timeInMS - time in milliseconds to be logged
- details - additional details to be logged with the time log
Return Value:
The current BreezzLogger Instance.
Usage:
forvendi.BreezzApi.LOGGER.addTimeLog('LoggerTest', 'Log', 'timeLogMetrics', 1337 ,'More details here.');
forvendi.BreezzApi.LOGGER.publish();
addMetricValue(String processName, String metricName, Long value)
Adds a metric value for the given process name and metric name.
Signature:
forvendi.BreezzApi.LOGGER.addMetricValue(String processName, String metricName, Long value);
Parameters:
- processName - name of the process associated with the metric
- metricName - name of the metric to be logged
- value - value of the metric to be logged
Return Value:
The current BreezzLogger Instance.
Usage:
forvendi.BreezzApi.LOGGER.addTimeLog('LoggerTest', 'Log', 'timeLogMetrics', Limits.getLimitDmlRows());
forvendi.BreezzApi.LOGGER.save();
Above code is adding a TimeLog into a metrics ald place in value label. Metrics are cached in the forvendi__B_Metric__c object at the end of the process.
addNumberOfExecutionsMetric(String processName)
Adds a metric to track the number of executions for a given process.
Signature:
forvendi.BreezzApi.LOGGER.addNumberOfExecutionsMetric(String processName);
Parameters:
- processName - the name of the process.
Return Value:
The current BreezzLogger Instance.
Usage:
1for ( Integer i = 0 ; i < 3 ; i++ ) {
2 forvendi.BreezzApi.LOGGER.addNumberOfExecutionsMetric('LoggerTest');
3}
4forvendi.BreezzApi.LOGGER.save();
Above code is adding a Number of Execution into a metrics add place in value label. Metrics are cached in the forvendi__B_Metric__c object at the end of the process.
addNumberOfProcessedRecordsMetric(String processName, Long val)
Adds a metric to track the number of processed records for a given process.
Signature:
forvendi.BreezzApi.LOGGER.addNumberOfProcessedRecordsMetric(String processName, Long val);
Parameters:
- processName - the name of the proces.
- val - the number of processed records.
Return Value:
The current BreezzLogger Instance.
Usage:
forvendi.BreezzApi.LOGGER.addNumberOfProcessedRecordsMetric('numberOfExecution', 1024);
forvendi.BreezzApi.LOGGER.save();
Above code is adding a Number of Processed Records Metric into a metrics add place in the value label. Process adding name of Metrics like Number Of Processed Records (in async). Metrics are cached in the forvendi__B_Metric__c object at the end of the process.
publish()
Publishes the logs and metrics to their respective destinations.
Signature:
forvendi.BreezzApi.LOGGER.publish();
Return Value:
void
save()
Save the logs and metrics to their respective destinations.
Signature:
forvendi.BreezzApi.LOGGER.save();
Return Value:
void