LogMessage
LogMessage Class
virtual
SUPPRESSWARNINGS
Provides the ability to generate string messages on demand, using String.format()
Group Logger Engine
See Logger
Constructors
LogMessage(unformattedMessage, messageInput)
Constructor to handle dynamically formatting a string with 1 input
Signature
global LogMessage(String unformattedMessage, Object messageInput)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
String formattedMessage = new LogMessage(‘Today is {0}’, System.today()).getMessage();
LogMessage(unformattedMessage, messageInput1, messageInput2)
Constructor to handle dynamically formatting a string with 2 inputs
Signature
global LogMessage(String unformattedMessage, Object messageInput1, Object messageInput2)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
String unformattedMessage = ‘my string with 2 inputs: {0} and {1}’; String formattedMessage = new LogMessage(unformattedMessage, ‘something’, ‘something else’).getMessage();
LogMessage(unformattedMessage, messageInput1, messageInput2, messageInput3)
SUPPRESSWARNINGS
Constructor to handle dynamically formatting a string with 3 inputs
Signature
global LogMessage(String unformattedMessage, Object messageInput1, Object messageInput2, Object messageInput3)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
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)
Constructor to handle dynamically formatting a string with a list of inputs
Signature
global LogMessage(String unformattedMessage, List<Object> messageInputs)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
String unformattedMessage = ‘my string with 1 input: {0}’; List<Object> arguments = new List<Object>{ System.now() }; String formattedMessage = new LogMessage(unformattedMessage, arguments).getMessage();
Methods
getMessage()
Returns the formatted string to use as the log entry’s message
Signature
global virtual String getMessage()Return Type
String
String