docs.unity3d.com
    Show / Hide Table of Contents

    Struct TextLoggerParser

    Parser logic

    Inherited Members
    ValueType.Equals(Object)
    ValueType.GetHashCode()
    ValueType.ToString()
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Namespace: Unity.Logging
    Syntax
    [BurstCompile]
    public struct TextLoggerParser

    Methods

    AddDecorateHandler(LogControllerScopedLock, LoggerManager.OutputWriterDecorateHandler, Boolean)

    Declaration
    [NotBurstCompatible]
    public static LogDecorateHandlerScope AddDecorateHandler(LogControllerScopedLock lock, LoggerManager.OutputWriterDecorateHandler handler, bool isBurstable = false)
    Parameters
    Type Name Description
    LogControllerScopedLock lock
    LoggerManager.OutputWriterDecorateHandler handler
    Boolean isBurstable
    Returns
    Type Description
    LogDecorateHandlerScope

    AddDecorateHandler(LoggerManager.OutputWriterDecorateHandler, Boolean)

    Declaration
    [NotBurstCompatible]
    public static LogDecorateHandlerScope AddDecorateHandler(LoggerManager.OutputWriterDecorateHandler handler, bool isBurstable = false)
    Parameters
    Type Name Description
    LoggerManager.OutputWriterDecorateHandler handler
    Boolean isBurstable
    Returns
    Type Description
    LogDecorateHandlerScope

    AddOutputHandler(TextLoggerParser.OutputWriterHandler, Boolean)

    Adds a delegate to process and generate logging output strings for a set of context structs.

    Declaration
    [NotBurstCompatible]
    public static IntPtr AddOutputHandler(TextLoggerParser.OutputWriterHandler handler, bool isBurstable = false)
    Parameters
    Type Name Description
    TextLoggerParser.OutputWriterHandler handler

    TextLoggerParser.OutputWriterHandler delegate to output logging context struct data.

    Boolean isBurstable

    True to Burst compile the handler and false if it's not Burst compatible.

    Returns
    Type Description
    IntPtr

    A token referencing this handler, used for removing the handler later.

    Remarks

    This method is invoked by source generated code and generally shouldn't be used directly.

    Since this method takes a delegate parameter, it's not Burst compatible itself. However, the method referenced by the delegate can be Burst compatible or not, depending on how it's implemented. If the handler method is Burst compatible, then pass true for isBurstable to Burst compile the handler, otherwise the handler always runs as managed code.

    ParseMessage(in FixedString512Bytes, in LogMessage, 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 bool ParseMessage(in FixedString512Bytes template, in LogMessage messageData, 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.

    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
    Boolean

    True if text message was successfully generated and false 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.

    ParseMessageTemplate(in LogMessage, in FixedString512Bytes, ref LogMemoryManager)

    Parses the LogMessage to UnsafeText

    Declaration
    public static UnsafeText ParseMessageTemplate(in LogMessage messageData, in FixedString512Bytes template, ref LogMemoryManager memAllocator)
    Parameters
    Type Name Description
    LogMessage messageData

    LogMessage to parse

    FixedString512Bytes template

    Template to use for the parsing

    LogMemoryManager memAllocator

    LogMemoryManager to get data from

    Returns
    Type Description
    UnsafeText

    UnsafeText with parsed message

    ParseMessageToJson(in LogMessage, in FixedString512Bytes, ref LogMemoryManager)

    Parses the LogMessage to Json UnsafeText

    Declaration
    public static UnsafeText ParseMessageToJson(in LogMessage messageData, in FixedString512Bytes _, ref LogMemoryManager memAllocator)
    Parameters
    Type Name Description
    LogMessage messageData

    LogMessage to parse

    FixedString512Bytes _

    Ignored in this case

    LogMemoryManager memAllocator

    LogMemoryManager to get data from

    Returns
    Type Description
    UnsafeText

    UnsafeText with parsed message

    RemoveOutputHandler(IntPtr)

    Removes an TextLoggerParser.OutputWriterHandler delegate from the parser.

    Declaration
    public static void RemoveOutputHandler(IntPtr token)
    Parameters
    Type Name Description
    IntPtr token

    Value returned by a previous call to AddOutputHandler(TextLoggerParser.OutputWriterHandler, Boolean) for the handler to remove.

    Remarks

    This method is invoked by source generated code and generally shouldn't be used directly.

    Once the handler is removed, context structs this handler serviced will no longer generated logging output. Log message that reference these context structs will still be outputted, but the context data will be missing.

    SetOutputHandlerForLevel(TextLoggerParser.OutputWriterLevelHandler, Boolean)

    Sets a delegate to process and generate logging output strings for LogLevel.

    Declaration
    [NotBurstCompatible]
    public static void SetOutputHandlerForLevel(TextLoggerParser.OutputWriterLevelHandler handler, bool isBurstable = false)
    Parameters
    Type Name Description
    TextLoggerParser.OutputWriterLevelHandler handler

    TextLoggerParser.OutputWriterLevelHandler delegate to output logging for LogLevel.

    Boolean isBurstable

    True to Burst compile the handler and false if it's not Burst compatible.

    Remarks

    This method is invoked by source generated code and generally shouldn't be used directly.

    Since this method takes a delegate parameter, it's not Burst compatible itself. However, the method referenced by the delegate can be Burst compatible or not, depending on how it's implemented. If the handler method is Burst compatible, then pass true for isBurstable to Burst compile the handler, otherwise the handler always runs as managed code.

    SetOutputHandlerForTimestamp(TextLoggerParser.OutputWriterTimestampHandler, Boolean)

    Sets a delegate to process and generate logging output strings for timestamps.

    Declaration
    [NotBurstCompatible]
    public static void SetOutputHandlerForTimestamp(TextLoggerParser.OutputWriterTimestampHandler handler, bool isBurstable = false)
    Parameters
    Type Name Description
    TextLoggerParser.OutputWriterTimestampHandler handler

    TextLoggerParser.OutputWriterTimestampHandler delegate to output logging for timestamps.

    Boolean isBurstable

    True to Burst compile the handler and false if it's not Burst compatible.

    Remarks

    This method is invoked by source generated code and generally shouldn't be used directly.

    Since this method takes a delegate parameter, it's not Burst compatible itself. However, the method referenced by the delegate can be Burst compatible or not, depending on how it's implemented. If the handler method is Burst compatible, then pass true for isBurstable to Burst compile the handler, otherwise the handler always runs as managed code.

    Back to top
    Terms of use
    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