docs.unity3d.com
    Show / Hide Table of Contents

    Class LogFormatterText

    Plain text formatter

    Inheritance
    Object
    LogFormatterText
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Logging
    Syntax
    [BurstCompile]
    public static class LogFormatterText

    Properties

    Formatter

    FormatterStruct that can format text

    Declaration
    public static FormatterStruct Formatter { get; }
    Property Value
    Type Description
    FormatterStruct

    Methods

    OnLogMessageFormatterFunc(in LogMessage, ref FormatterStruct, ref FixedString512Bytes, ref UnsafeText, IntPtr, IntPtr, Allocator)

    Parses the LogMessage to UnsafeText

    Declaration
    [BurstCompile]
    [MonoPInvokeCallback(typeof(OnLogMessageFormatterDelegate.Delegate))]
    public static int OnLogMessageFormatterFunc(in LogMessage messageData, ref FormatterStruct formatter, ref FixedString512Bytes template, ref UnsafeText messageOutput, IntPtr memoryManager, IntPtr userData, Allocator allocator)
    Parameters
    Type Name Description
    LogMessage messageData

    LogMessage to parse

    FormatterStruct formatter

    Formatter that sink is using

    FixedString512Bytes template

    Template to use for the parsing

    UnsafeText messageOutput

    Memory to store the message

    IntPtr memoryManager

    LogMemoryManager to get data from

    IntPtr userData

    Not Used

    Allocator allocator

    If any memory allocation is needed - this allocator will be used

    Returns
    Type Description
    Int32

    Length of the messageOutput. Negative on error

    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
    FixedString512Bytes template

    Template for the message, like '{Timestamp} | {Level} | {Message}'

    LogMessage messageData

    A LogMessage generated by the TextLogger to generated formatted output for.

    FormatterStruct formatter

    Formatter that sink is using

    UnsafeText messageOutput

    Returns the text output generated from the log message.

    FixedString512Bytes errorMessage

    Returns an error message string, should a problem parsing the message occur.

    LogMemoryManager memAllocator

    Reference to LogMemoryManager holding memory buffers for the passed in message.

    Returns
    Type Description
    Int32

    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 UnsafeText variable while any error messages are returned through a separate FixedString variable.

    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 LogMemoryManager instance holding the backing memory for the passed in LogMessage. Generally this is the MemoryManager within the Logger the Sink resides in.

    WriteMessage(in LogMessage, ref FormatterStruct, ref HeaderData, ref UnsafeText, ref FixedString512Bytes, ref LogMemoryManager)

    Method that is used to parse the {Message} itself

    Declaration
    public static bool WriteMessage(in LogMessage logMessage, ref FormatterStruct formatter, ref HeaderData headerData, ref UnsafeText messageOutput, ref FixedString512Bytes errorMessage, ref LogMemoryManager memAllocator)
    Parameters
    Type Name Description
    LogMessage logMessage

    Log message

    FormatterStruct formatter

    Current formatter

    HeaderData headerData

    Parsed binary header data

    UnsafeText messageOutput

    Output of this function

    FixedString512Bytes errorMessage

    Returns an error message string, should a problem parsing the message occur.

    LogMemoryManager memAllocator

    Memory allocator that contains other fields of the message

    Returns
    Type Description
    Boolean

    True if no errors happened

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023