LogMessage
LogMessage Class
Section titled “LogMessage Class”virtual
SUPPRESSWARNINGS
Provides the ability to generate string messages on demand, using String.format()
Group Logger Engine
See Logger
Constructors
Section titled “Constructors”LogMessage(unformattedMessage, messageInput)
Section titled “LogMessage(unformattedMessage, messageInput)”Constructor to handle dynamically formatting a string with 1 input
Signature
Section titled “Signature”global LogMessage(String unformattedMessage, Object messageInput)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| unformattedMessage | String | The base string to use for your log message |
| messageInput | Object | The replacement text to use for 1 placeholder in the unformatted message |
Example
Section titled “Example”String formattedMessage = new LogMessage('Today is {0}', System.today()).getMessage();
LogMessage(unformattedMessage, messageInput1, messageInput2)
Section titled “LogMessage(unformattedMessage, messageInput1, messageInput2)”Constructor to handle dynamically formatting a string with 2 inputs
Signature
Section titled “Signature”global LogMessage(String unformattedMessage, Object messageInput1, Object messageInput2)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| unformattedMessage | String | The base string to use for your log message |
| messageInput1 | Object | The replacement text to use for the first placeholder in the unformatted message |
| messageInput2 | Object | The replacement text to use for the second placeholder in the unformatted message |
Example
Section titled “Example”String unformattedMessage = 'my string with 2 inputs: {0} and {1}'; String formattedMessage = new LogMessage(unformattedMessage, 'something', 'something else').getMessage();
LogMessage(unformattedMessage, messageInput1, messageInput2, messageInput3)
Section titled “LogMessage(unformattedMessage, messageInput1, messageInput2, messageInput3)”SUPPRESSWARNINGS
Constructor to handle dynamically formatting a string with 3 inputs
Signature
Section titled “Signature”global LogMessage(String unformattedMessage, Object messageInput1, Object messageInput2, Object messageInput3)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| unformattedMessage | String | The base string to use for your log message |
| messageInput1 | Object | The replacement text to use for the first placeholder in the unformatted message |
| messageInput2 | Object | The replacement text to use for the second placeholder in the unformatted message |
| messageInput3 | Object | The replacement text to use for the third placeholder in the unformatted message |
Example
Section titled “Example”String unformattedMessage = 'my string with 3 inputs: {0} and then {1} and finally {2}'; String formattedMessage = new LogMessage(unformattedMessage, 'something', 'something else', 'one more').getMessage();
LogMessage(unformattedMessage, messageInputs)
Section titled “LogMessage(unformattedMessage, messageInputs)”Constructor to handle dynamically formatting a string with a list of inputs
Signature
Section titled “Signature”global LogMessage(String unformattedMessage, List<Object> messageInputs)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| unformattedMessage | String | The base string to use for your log message |
| messageInputs | List | The list of inputs text to use for any placeholders in the unformatted message |
Example
Section titled “Example”String unformattedMessage = 'my string with 1 input: {0}'; List<Object> arguments = new List<Object>{ System.now() }; String formattedMessage = new LogMessage(unformattedMessage, arguments).getMessage();
Methods
Section titled “Methods”getMessage()
Section titled “getMessage()”Returns the formatted string to use as the log entry's message
Signature
Section titled “Signature”global virtual String getMessage()Return Type
Section titled “Return Type”String
String