Skip to content
pozil edited this page Nov 14, 2024 · 14 revisions

Log Class

Generic logging framework that persists across DML reversions by publishing a Platform Event

Group Shared Code

Fields

currentInstance

private instance of this log class that backs the singleton get() method.

Signature

private static currentInstance

Type

Log


buffer

private list of LogMessage objects to be published in the future

Signature

private buffer

Type

List<LogMessage>

Constructors

Log()

establishes the buffer, if one doesn't yet exist private, to ensure we can't directly construct this class. Use the Singleton, Luke.

Signature

private Log()

Methods

get()

Singleton pattern get method.

Signature

public static Log get()

Return Type

Log


add(messageToLog)

Add a message to the buffer without publishing it. Assumes a null severity

Signature

public void add(String messageToLog)

Parameters

Name Type Description
messageToLog String The string message to add to the buffer.

Return Type

void


add(messageToLog, severity)

Add a message to the buffer without publishing it.

Signature

public void add(String messageToLog, LogSeverity severity)

Parameters

Name Type Description
messageToLog String The string message to add to the buffer.
severity LogSeverity LogSeverity enum

Return Type

void


add(exceptionToLog)

Add an formated exception message to the buffer without publishing it. Assumes a null Severity

Signature

public void add(Exception exceptionToLog)

Parameters

Name Type Description
exceptionToLog Exception Exception to format and log

Return Type

void


add(exceptionToLog, severity)

Add an formated exception message to the buffer without publishing it.

Signature

public void add(Exception exceptionToLog, LogSeverity severity)

Parameters

Name Type Description
exceptionToLog Exception Exception to format and log
severity LogSeverity LogSeverity enum

Return Type

void


publish()

Publish any messages currently in the buffer, without adding any new ones.

Signature

public void publish()

Return Type

void


publish(exceptionToLog)

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.

Signature

public void publish(Exception exceptionToLog)

Parameters

Name Type Description
exceptionToLog Exception exception to format and log

Return Type

void


publish(messageToLog)

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.

Signature

public void publish(String messageToLog)

Parameters

Name Type Description
messageToLog String String to log

Return Type

void

Clone this wiki locally