Skip to content

Commit

Permalink
Moved some code over to use the logger service
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-baillie-ortoo committed Apr 7, 2022
1 parent 41658f9 commit 6238a10
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Sobject> The records that match
Expand All @@ -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 );
Expand All @@ -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 );
}
}

Expand Down

0 comments on commit 6238a10

Please sign in to comment.