Method ParseMessage
ParseMessage(ref FixedString512Bytes, in LogMessage, ref FormatterStruct, ref UnsafeText, ref FixedString512Bytes, ref LogMemoryManager)
Processes a TextLogger message and returns a text string containing the message text along with the context data referenced in the message.
Declaration
public static int ParseMessage(ref FixedString512Bytes template, in LogMessage messageData, ref FormatterStruct formatter, ref UnsafeText messageOutput, ref FixedString512Bytes errorMessage, ref LogMemoryManager memAllocator)
Parameters
Type | Name | Description |
---|---|---|
Fixed |
template | Template for the message, like '{Timestamp} | {Level} | {Message}' |
Log |
messageData | A Log |
Formatter |
formatter | Formatter that sink is using |
Unsafe |
messageOutput | Returns the text output generated from the log message. |
Fixed |
errorMessage | Returns an error message string, should a problem parsing the message occur. |
Log |
memAllocator | Reference to Log |
Returns
Type | Description |
---|---|
int | messageOutput length or negative number if an error occurred. |
Remarks
This method is called by a TextLogger Sinks to extract the data from the message and generate a formatted text string, which can be written
to an output stream. The message output is returned through a Unsafe
The returned message string is allocated internally according to the size/length of the message, and therefore the caller should pass in an empty messageOutput variable. Furthermore, the string memory is allocated from the Temp pool and must not be referenced after the end of the frame. If the message needs to be held longer, it must be copied to a Persistent buffer. The caller should still Dispose the string once it's finished with it.
If a problem occurs parsing/writing the output text, a separate errorMessage string is returned; a value of 'false' is returned in this case. Otherwise errorMessage string will be empty and 'true' is returned. Note that messageOutput may still hold valid text even if a error/failure occurs; it'll be a "partial" output string and missing some or all of the data.
The caller must also pass in a reference to the Log