Skip to content

dlisovsky/logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Salesforce Logger

An exmaple of usage:

try {
    hey.Logger.debug('Hey Logger!');
} catch (Exception ex) {
    hey.Logger.exception(ex);
    throw ex;
} finally {
    hey.Logger.publish();
}

OR

try {
    hey.Logger.debug('test debug message');
    hey.Logger.debug(new List<Object>{1, 'Test', 2.25});
    hey.Logger.debug('template {0}', new User(Email = '[email protected]'));
    hey.Logger.debug('template {0} {1}', new List<Object>{
        1,
        2
    });
    
    HttpRequest req = new HttpRequest();
    req.setEndpoint('https://slack.com');
    req.setMethod('GET');
    hey.Logger.debug(new Http().send(req).getBody());
    
    hey.Logger.error('test error message');
    hey.Logger.info('test error message');

    System.debug(1 / 0); // simulate exception.
} catch (Exception ex) {
    hey.Logger.exception(ex);
    throw ex;
} finally {
    hey.Logger.publish();
}

Configuration

The logger can be configured via Custom Metadata Types. It supports:

  • A ILogger implementation that publishes the Log

    • The default PlatformEventLoggerImpl implementation publishes the log to Salesforce Platform Event
  • A list of the ILogHandler implementations to handle the published Log

    • The default SlackLogHandler implementation attaches the Log as a snippet to the configured Slack channel

About

Salesforce Logger - hey.Logger

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published