docs.unity3d.com
    Show / Hide Table of Contents

    Struct LogController

    Burst-friendly backend for Logger that contains LoggerHandle, LogMemoryManager, DispatchQueue and is able to answer if this particular LogLevel is supported by this Logger.

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

    Constructors

    LogController(LoggerHandle, in LogMemoryManagerParameters)

    Constructor that initializes MemoryManager and DispatchQueue. Uses LoggerHandle provided by the caller.

    Declaration
    public LogController(LoggerHandle loggerHandle, in LogMemoryManagerParameters memoryParameters)
    Parameters
    Type Name Description
    LoggerHandle loggerHandle

    Unique id of the parent Logger

    LogMemoryManagerParameters memoryParameters

    Parameters used to initialize MemoryManager. Could be used to specify particular size of its buffers.

    Fields

    DispatchQueue

    Double-buffered queue that is used for dispatching LogMessages. DispatchQueue

    Declaration
    public DispatchQueue DispatchQueue
    Field Value
    Type Description
    DispatchQueue

    Handle

    Unique id of the Logger

    Declaration
    public LoggerHandle Handle
    Field Value
    Type Description
    LoggerHandle

    MemoryManager

    Memory manager that stores binary representation of structured logging. LogMemoryManager

    Declaration
    public LogMemoryManager MemoryManager
    Field Value
    Type Description
    LogMemoryManager

    Properties

    IsCreated

    True if Logging system has been initialized.

    Declaration
    public readonly bool IsCreated { get; }
    Property Value
    Type Description
    Boolean

    NeedsStackTrace

    True if any sink requested stack trace. If this is false - logging would work faster.

    Declaration
    public readonly bool NeedsStackTrace { get; }
    Property Value
    Type Description
    Boolean

    Methods

    AddDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler>)

    The function that can add function based decorator. Internally used by LogDecorateHandlerScope, better to use that instead. RemoveDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler>)

    Declaration
    public void AddDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler> func)
    Parameters
    Type Name Description
    FunctionPointer<LoggerManager.OutputWriterDecorateHandler> func

    Function based decorator to add

    BeginEditDecoratePayloadHandles(ref LogController, out Int32)

    Function that is called by the logging codegeneration.

    Used to populate Decorate array. See LogDecorateScope documentation for more details

    This function is called before decoration, EndEditDecoratePayloadHandles(ref LogController, Int32) must be called after LogDecorateScope

    Declaration
    public static ref FixedList4096Bytes<PayloadHandle> BeginEditDecoratePayloadHandles(ref LogController lc, out int nBefore)
    Parameters
    Type Name Description
    LogController lc

    LogController to add decorations to

    Int32 nBefore

    Current count of Decorations - PayloadHandles at the moment

    Returns
    Type Description
    FixedList4096Bytes<PayloadHandle>

    Array of Decorations - PayloadHandles

    DecorateHandlerCount()

    Returns count of Function-based Decorators (that you can add with Log.Decorate(function) or AddDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler>) and remove with RemoveDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler>)) They will be executed each time log message is created

    Declaration
    public int DecorateHandlerCount()
    Returns
    Type Description
    Int32

    Count of Function-based Decorators

    DecoratePayloadsCount()

    Returns count of constant Decorators (that you can add with Log.Decorate("name", value)) They will be copied to new log message payload each time log message is created

    Declaration
    public int DecoratePayloadsCount()
    Returns
    Type Description
    Int32

    Count of constant Decorators

    DispatchMessage(ref LogMessage)

    Dispatches a LogMessage

    Declaration
    public void DispatchMessage(ref LogMessage message)
    Parameters
    Type Name Description
    LogMessage message

    Message structure

    Remarks

    This method is thread-safe and can be called from any thread context or Job. If successful, the Logging system will take over ownership of the message data and ensure the memory buffer is released after the message has been processed.

    EndEditDecoratePayloadHandles(ref LogController, Int32)

    Function that is called by the logging codegeneration.

    Used to populate Decorate array. See LogDecorateScope documentation for more details

    This function is called after decoration, BeginEditDecoratePayloadHandles(ref LogController, out Int32) must be called before LogDecorateScope

    Declaration
    public static FixedList64Bytes<PayloadHandle> EndEditDecoratePayloadHandles(ref LogController lc, int nBefore)
    Parameters
    Type Name Description
    LogController lc

    LogController to add decorations to

    Int32 nBefore

    Same variable that was returned in BeginEditDecoratePayloadHandles(ref LogController, out Int32) call

    Returns
    Type Description
    FixedList64Bytes<PayloadHandle>

    Array of just added Decorations - PayloadHandles

    HasSinksFor(LogLevel)

    Returns true if is supported by at least one in this LogController

    Declaration
    public bool HasSinksFor(LogLevel level)
    Parameters
    Type Name Description
    LogLevel level

    LogLevel enum

    Returns
    Type Description
    Boolean

    Returns true if is supported by at least one in this LogController

    LogDispatched()

    Count of log messages dispatched and waiting to be processed

    Declaration
    public int LogDispatched()
    Returns
    Type Description
    Int32

    Count of log messages dispatched and waiting to be processed

    MustBeValid()

    Checks that IsCreated == true. Throws otherwise.

    Declaration
    [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")]
    public void MustBeValid()
    Exceptions
    Type Condition
    Exception

    Throws if IsCreated == false

    RemoveDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler>)

    The function that remove function based decorator that was added by AddDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler>) Internally used by LogDecorateHandlerScope, better to use that instead. AddDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler>)

    Declaration
    public void RemoveDecorateHandler(FunctionPointer<LoggerManager.OutputWriterDecorateHandler> func)
    Parameters
    Type Name Description
    FunctionPointer<LoggerManager.OutputWriterDecorateHandler> func

    Function based decorator to remove

    Shutdown()

    Stops Logging and releases the memory and destroys systems created by LogController.

    Declaration
    public void Shutdown()
    Remarks

    This must be called from the main thread (do not call from a Job) after all Logging calls have completed; any log messages "in flight" will be discarded.

    IMPORTANT: Accessing the Payload buffer of a log message when Shutdown is called, e.g. during an asynchronous I/O operation, will result in undefined behavior.

    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