docs.unity3d.com
    Show / Hide Table of Contents

    Class Logger

    Main class of Logging library. Contains Sinks, unique identifier LoggerHandle

    Inheritance
    Object
    Logger
    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
    public class Logger : IDisposable

    Constructors

    Logger(LoggerConfig)

    Constructor

    Declaration
    public Logger(LoggerConfig config)
    Parameters
    Type Name Description
    LoggerConfig config

    Contains configuration of the logger

    Fields

    Config

    Config that was used in Logger construction

    Declaration
    public readonly LoggerConfig Config
    Field Value
    Type Description
    LoggerConfig

    Handle

    Unique id

    Declaration
    public readonly LoggerHandle Handle
    Field Value
    Type Description
    LoggerHandle

    Properties

    MinimalLogLevelAcrossAllSystems

    Minimal LogLevel that this Logger will process (means it has sinks for it)

    Declaration
    public LogLevel MinimalLogLevelAcrossAllSystems { get; }
    Property Value
    Type Description
    LogLevel

    SinksCount

    Returns count of sinks that this Logger has

    Declaration
    public int SinksCount { get; }
    Property Value
    Type Description
    Int32

    Methods

    AddSink(SinkConfiguration)

    Creates new sink using SinkConfiguration

    Declaration
    public SinkSystemBase AddSink(SinkConfiguration sc)
    Parameters
    Type Name Description
    SinkConfiguration sc

    Configuration to create a sink

    Returns
    Type Description
    SinkSystemBase

    Newly created sink

    AddSink(SinkConfiguration, ref LogControllerScopedLock)

    Creates new sink using SinkConfiguration

    Declaration
    public SinkSystemBase AddSink(SinkConfiguration sc, ref LogControllerScopedLock logLock)
    Parameters
    Type Name Description
    SinkConfiguration sc

    Configuration to create a sink

    Unity.Logging.Internal.LogControllerScopedLock logLock

    Lock that holds this logger's LogController

    Returns
    Type Description
    SinkSystemBase

    Newly created sink

    Dispose()

    Disposes the Logger. See IDisposable

    Declaration
    public void Dispose()
    Implements
    IDisposable.Dispose()

    GetOrCreateSink<T>(SinkConfiguration)

    Get or create sink of type T

    Declaration
    public T GetOrCreateSink<T>(SinkConfiguration sc)
        where T : SinkSystemBase
    Parameters
    Type Name Description
    SinkConfiguration sc

    Configuration of the sink

    Returns
    Type Description
    T

    Existing or created sink

    Type Parameters
    Name Description
    T

    SinkSystemBase

    GetSink(Int32)

    Returns sink number i. Used for debugging

    Declaration
    public SinkSystemBase GetSink(int i)
    Parameters
    Type Name Description
    Int32 i

    index of the sink

    Returns
    Type Description
    SinkSystemBase

    Returns sink number i

    GetSink<T>()

    Returns the sink of type T. Will return first one if there are several ones of the type T

    Declaration
    public T GetSink<T>()
        where T : SinkSystemBase
    Returns
    Type Description
    T

    Existing sink of type T or default

    Type Parameters
    Name Description
    T

    SinkSystemBase type

    HasSinksFor(LogLevel)

    Returns true if this Logger can process messages with LogLevel level.

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

    True if this Logger can process messages with LogLevel level.

    SetMinimalLogLevelAcrossAllSinks(LogLevel)

    Changes LogLevel for all sinks in the logger. No need to call UpdateMinimalLogLevelAcrossAllSinks() after this. Update will take effect only after logger's update because of async nature of the logging. So if you want to do the change synchronously - please call Unity.Logging.Internal.LoggerManager.FlushAll>

    Declaration
    public void SetMinimalLogLevelAcrossAllSinks(LogLevel newLogLevel)
    Parameters
    Type Name Description
    LogLevel newLogLevel

    LogLevel to set to all sinks in the logger

    UpdateMinimalLogLevelAcrossAllSinks()

    Method that updates internal cached MinimalLogLevelAcrossAllSinks, and HasNoSinks please call it if you update sink's MinimalLogLevel or add/remove sinks Update will take effect only after logger's update because of async nature of the logging. So if you want to do the change synchronously - please call Unity.Logging.Internal.LoggerManager.FlushAll>

    Declaration
    public void UpdateMinimalLogLevelAcrossAllSinks()
    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