docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Logging

    Defines logging levels for logging within PolySpatial.

    Inheritance
    object
    Logging
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.PolySpatial
    Assembly: Unity.PolySpatial.Core.dll
    Syntax
    public static class Logging

    Methods

    IsCategoryEnabled(LogCategory)

    Returns whether logging is currently enabled for the specified category, considering build configuration.

    Declaration
    public static bool IsCategoryEnabled(LogCategory cat)
    Parameters
    Type Name Description
    LogCategory cat

    The logging category to query.

    Returns
    Type Description
    bool

    True if the category is enabled (in development or assertion builds); otherwise, false. In non-development builds this always returns false.

    IsLogLevelAlwaysEnabled(LogLevel)

    Indicates whether a given log level is always enabled regardless of category settings.

    Declaration
    public static bool IsLogLevelAlwaysEnabled(LogLevel type)
    Parameters
    Type Name Description
    LogLevel type

    The log level to query.

    Returns
    Type Description
    bool

    True if messages at the specified level are always logged; otherwise, false.

    IsStackTraceEnabled(LogCategory)

    Returns whether stack traces are enabled for the specified category.

    Declaration
    public static bool IsStackTraceEnabled(LogCategory cat)
    Parameters
    Type Name Description
    LogCategory cat

    The logging category to query.

    Returns
    Type Description
    bool

    True if stack traces are enabled for the category (in development or assertion builds); otherwise, false. In non-development builds this always returns false.

    Log(object)

    Logs a general diagnostic message at Log severity to the Diagnostics category.

    Declaration
    public static void Log(object message)
    Parameters
    Type Name Description
    object message

    The message object to log.

    Log(object, LogLevel)

    Log a message with the PolySpatial logging system. Will log to the Debug category.

    Declaration
    public static void Log(object message, LogLevel severity = LogLevel.Log)
    Parameters
    Type Name Description
    object message

    The message content to log.

    LogLevel severity

    The log severity to log at.

    Log(LogCategory, object, LogLevel, StackTrace)

    Logs a message to the specified category and severity, optionally controlling stack trace behavior.

    Declaration
    public static void Log(LogCategory category, object message, LogLevel severity = LogLevel.Log, Logging.StackTrace stackTrace = StackTrace.Default)
    Parameters
    Type Name Description
    LogCategory category

    The category to log under.

    object message

    The message object to log.

    LogLevel severity

    The severity at which to log. Defaults to Log.

    Logging.StackTrace stackTrace

    Stack trace preference for this call. Defaults to Default which uses configured behavior. Use Always to force a stack trace, or Never to suppress it.

    LogDebug1(LogCategory, object, StackTrace)

    Logs a development-only Debug1 message to the specified category.

    Declaration
    [Conditional("DEVELOPMENT_BUILD")]
    public static void LogDebug1(LogCategory category, object message, Logging.StackTrace stackTrace = StackTrace.Default)
    Parameters
    Type Name Description
    LogCategory category

    The category to log under.

    object message

    The message object to log.

    Logging.StackTrace stackTrace

    Stack trace preference for this call. Defaults to Default.

    Remarks

    This method is compiled and executed only in DEVELOPMENT_BUILD builds.

    LogDebug2(LogCategory, object, StackTrace)

    Logs a development-only Debug2 message to the specified category.

    Declaration
    [Conditional("DEVELOPMENT_BUILD")]
    public static void LogDebug2(LogCategory category, object message, Logging.StackTrace stackTrace = StackTrace.Default)
    Parameters
    Type Name Description
    LogCategory category

    The category to log under.

    object message

    The message object to log.

    Logging.StackTrace stackTrace

    Stack trace preference for this call. Defaults to Default.

    Remarks

    This method is compiled and executed only in DEVELOPMENT_BUILD builds.

    LogError(object)

    Logs a general diagnostic error at Error severity to the Diagnostics category.

    Declaration
    public static void LogError(object message)
    Parameters
    Type Name Description
    object message

    The message object to log.

    LogError(LogCategory, object)

    Logs an error message to the specified category.

    Declaration
    public static void LogError(LogCategory category, object message)
    Parameters
    Type Name Description
    LogCategory category

    The category to log under.

    object message

    The message object to log.

    LogNoStacktrace(LogCategory, object, LogLevel)

    Logs a message without a stack trace, regardless of category stack trace settings.

    Declaration
    public static void LogNoStacktrace(LogCategory category, object message, LogLevel level)
    Parameters
    Type Name Description
    LogCategory category

    The category to log under.

    object message

    The message object to log.

    LogLevel level

    The severity level at which to log.

    Remarks

    Overrides the default stack trace behavior and suppresses stack traces for this call.

    LogWarning(object)

    Logs a general diagnostic warning at Warning severity to the Diagnostics category.

    Declaration
    public static void LogWarning(object message)
    Parameters
    Type Name Description
    object message

    The message object to log.

    LogWarning(LogCategory, object)

    Logs a warning message to the specified category.

    Declaration
    public static void LogWarning(LogCategory category, object message)
    Parameters
    Type Name Description
    LogCategory category

    The category to log under.

    object message

    The message object to log.

    SetCategoryEnabled(LogCategory, bool)

    Enables or disables logging for a specific category.

    Declaration
    public static void SetCategoryEnabled(LogCategory cat, bool enabled)
    Parameters
    Type Name Description
    LogCategory cat

    The logging category to modify.

    bool enabled

    True to enable logging; false to disable.

    Remarks

    Persists the change to editor preferences so it survives domain reloads and editor restarts.

    SetLogLevelAlwaysEnabled(LogLevel, bool)

    Sets whether a given log level should be always enabled.

    Declaration
    public static void SetLogLevelAlwaysEnabled(LogLevel type, bool enabled)
    Parameters
    Type Name Description
    LogLevel type

    The log level to modify.

    bool enabled

    True to always log messages at this level; false to respect category settings.

    Remarks

    Persists the change to editor preferences.

    SetStackTraceEnabled(LogCategory, bool)

    Enables or disables stack traces for a specific logging category.

    Declaration
    public static void SetStackTraceEnabled(LogCategory cat, bool enabled)
    Parameters
    Type Name Description
    LogCategory cat

    The logging category to modify.

    bool enabled

    True to include stack traces; false to omit them.

    Remarks

    Persists the change to editor preferences.

    ShouldLogMessage(LogCategory, LogLevel)

    Determines whether a message of the given category and level should be logged.

    Declaration
    public static bool ShouldLogMessage(LogCategory category, LogLevel type)
    Parameters
    Type Name Description
    LogCategory category

    The category of the message.

    LogLevel type

    The severity level of the message.

    Returns
    Type Description
    bool

    True if the message should be emitted (because the level is always enabled or the category is enabled); otherwise, false.

    ShouldLogStackTrace(LogCategory, LogLevel)

    Determines whether a stack trace should accompany a message of the given category and level.

    Declaration
    public static bool ShouldLogStackTrace(LogCategory category, LogLevel type)
    Parameters
    Type Name Description
    LogCategory category

    The category of the message.

    LogLevel type

    The severity level of the message.

    Returns
    Type Description
    bool

    True if stack traces are enabled for the level and either the level is always enabled or the category has stack traces enabled; otherwise, false.

    ToLogType(LogLevel)

    Maps a PolySpatial LogLevel to a Unity LogType.

    Declaration
    public static LogType ToLogType(LogLevel level)
    Parameters
    Type Name Description
    LogLevel level

    The PolySpatial log level.

    Returns
    Type Description
    LogType

    The corresponding Unity log type.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)