From 6238a107322e2a2a3a8cd88cabb5a6ce87f8bd58 Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Thu, 7 Apr 2022 14:50:30 +0100 Subject: [PATCH] Moved some code over to use the logger service --- .../default/classes/common/fflib_Application.cls | 1 - .../services/logger/classes/LoggerServiceImpl.cls | 3 +-- .../fflib-extension/caching/CachedSoqlExecutor.cls | 14 +++++++------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/framework/default/fflib/default/classes/common/fflib_Application.cls b/framework/default/fflib/default/classes/common/fflib_Application.cls index f2c5792a2e6..be4f5c25504 100644 --- a/framework/default/fflib/default/classes/common/fflib_Application.cls +++ b/framework/default/fflib/default/classes/common/fflib_Application.cls @@ -192,7 +192,6 @@ public virtual class fflib_Application } try { - // TODO: test? if ( !serviceInterfaceName.endsWith( 'ILoggerService' ) ) { LoggerService.log( LoggerService.LEVEL.INFO, 'Using default implementation ' + defaultServiceName + ' for ' + serviceInterfaceName ); diff --git a/framework/default/modules/logger/services/logger/classes/LoggerServiceImpl.cls b/framework/default/modules/logger/services/logger/classes/LoggerServiceImpl.cls index b9a629a9f64..18ff0144d0a 100644 --- a/framework/default/modules/logger/services/logger/classes/LoggerServiceImpl.cls +++ b/framework/default/modules/logger/services/logger/classes/LoggerServiceImpl.cls @@ -6,10 +6,9 @@ */ public with sharing class LoggerServiceImpl implements ILoggerService { - // TODO: Test the static wrapper and references to the custom setting / defaults // TODO: what can we output in the UI? Flag on custom settings to decide - // TODO: search for any System.debug in the code // TODO: notes on testing if the logger is used - you have to set up the custom metadata first - create a test utils for it + // TODO: implement Exception.clearContext private static final String BLANK_LINE = ''; diff --git a/framework/default/ortoo-core/default/classes/fflib-extension/caching/CachedSoqlExecutor.cls b/framework/default/ortoo-core/default/classes/fflib-extension/caching/CachedSoqlExecutor.cls index 1f68b28a99e..c3c187d00af 100644 --- a/framework/default/ortoo-core/default/classes/fflib-extension/caching/CachedSoqlExecutor.cls +++ b/framework/default/ortoo-core/default/classes/fflib-extension/caching/CachedSoqlExecutor.cls @@ -48,7 +48,7 @@ public inherited sharing class CachedSoqlExecutor //NOPMD: incorrect report of t * If so, the cached versions are returned. * If not, the query is executed against the database and the result cached. * If, for any reason, a cache read or write cannot be performed, the method will continue without an exception. - * Errors can be seen in the System.debug log. + * Errors can be seen in the configured log destination (uses LoggerService) * * @param String The SOQL to return the results for * @return List The records that match @@ -70,21 +70,21 @@ public inherited sharing class CachedSoqlExecutor //NOPMD: incorrect report of t { if ( cacheWrapper.isACache() ) { - System.debug( LoggingLevel.INFO, 'Opportunity to use Platform Cache skipped since user does not have required permission' ); // TODO: can we get the permission name into this? + LoggerService.log( LoggerService.Level.ERROR, 'Opportunity to use Platform Cache skipped since user does not have required permission' ); // TODO: can we get the permission name into this? } } } catch ( Exception e ) { - System.debug( LoggingLevel.ERROR, 'Attempt to read from the Platform Cache failed for the SOQL: ' + soql ); - System.debug( LoggingLevel.ERROR, e ); + LoggerService.log( LoggerService.Level.ERROR, 'Attempt to read from the Platform Cache failed for the SOQL: ' + soql ); + LoggerService.log( e ); } if ( returnValues == null ) { if ( cacheWrapper.hasAccessToCache() && cacheWrapper.isACache() ) { - System.debug( LoggingLevel.INFO, 'Platform Cache miss when running the SOQL: ' + soql ); + LoggerService.log( LoggerService.Level.INFO, 'Platform Cache miss when running the SOQL: ' + soql ); } returnValues = Database.query( soql ); @@ -98,8 +98,8 @@ public inherited sharing class CachedSoqlExecutor //NOPMD: incorrect report of t } catch ( Exception e ) { - System.debug( LoggingLevel.ERROR, 'Attempt to write into the Platform Cache failed for the SOQL: ' + soql ); - System.debug( LoggingLevel.ERROR, e ); + LoggerService.log( LoggerService.Level.ERROR, 'Attempt to write into the Platform Cache failed for the SOQL: ' + soql ); + LoggerService.log( e ); } }