-
Notifications
You must be signed in to change notification settings - Fork 459
Log
Generic logging framework that persists across DML reversions by publishing a Platform Event
Group Shared Code
private instance of this log class that backs the singleton get() method.
private static currentInstance
private list of LogMessage objects to be published in the future
private buffer
List<LogMessage>
establishes the buffer, if one doesn't yet exist private, to ensure we can't directly construct this class. Use the Singleton, Luke.
private Log()
Singleton pattern get
method.
public static Log get()
Add a message to the buffer without publishing it. Assumes a null severity
public void add(String messageToLog)
Name | Type | Description |
---|---|---|
messageToLog | String | The string message to add to the buffer. |
void
Add a message to the buffer without publishing it.
public void add(String messageToLog, LogSeverity severity)
Name | Type | Description |
---|---|---|
messageToLog | String | The string message to add to the buffer. |
severity | LogSeverity | LogSeverity enum |
void
Add an formated exception message to the buffer without publishing it. Assumes a null Severity
public void add(Exception exceptionToLog)
Name | Type | Description |
---|---|---|
exceptionToLog | Exception | Exception to format and log |
void
Add an formated exception message to the buffer without publishing it.
public void add(Exception exceptionToLog, LogSeverity severity)
Name | Type | Description |
---|---|---|
exceptionToLog | Exception | Exception to format and log |
severity | LogSeverity | LogSeverity enum |
void
Publish any messages currently in the buffer, without adding any new ones.
public void publish()
void
Auto-format exception details, add it to the log buffer, and then publish the current buffer. Use the equivelent add method if you intend to add multiple messages rapidly to minimize DML usage.
public void publish(Exception exceptionToLog)
Name | Type | Description |
---|---|---|
exceptionToLog | Exception | exception to format and log |
void
Auto-format a custom log message string, add it to the log buffer, and then publish the current buffer. Use the equivelent add method if you intend to add multiple messages rapidly to minimize DML usage.
public void publish(String messageToLog)
Name | Type | Description |
---|---|---|
messageToLog | String | String to log |
void