Search Results for

    Show / Hide Table of Contents

    Class UnityObjectLoggerExt

    Utility class for UnityEngine.Object subclasses (MonoBehaviour, Component, Editor, etc.) that want to use the extended logging capabilities below:

    • Option to log ThreadId, class name, object name, game time or other common info to log messages.
    • Configure the info PER CLASS. Useful for debugging specific classes.
    Inheritance
    Object
    UnityObjectLoggerExt
    Namespace: NoSuchStudio.Common
    Assembly: NoSuchStudio-Common.dll
    Syntax
    public static class UnityObjectLoggerExt
    Remarks

    This class keeps track of all types that use it and creates a UnityEngine.Logger for each. Any messages logged through the extension methods will have the info based on the LoggerConfig for that type prepended to the message.

    MyClass myObj = new MyClass(); // MyClass extends UnityEngine.Object (i.e. MonoBehaviour, Editor, Component, ...)
    myObj.LogLog("Hello World!"); 
    // will print "[1][4.56](MyClass)(myObjName) Hello World!"

    Using sample code like below, you can filter your logs by class.

    UnityObjectLoggerExt.GetLoggerByType<MyClass>().logger.filterLogType = LogType.Error;

    Using sample code like below, you can change the logging config for each class.

    UnityObjectLoggerExt.GetLoggerByType<MyClass>().loggerConfig.logGameTime = false;

    Fields

    loggers

    Declaration
    public static readonly Dictionary<Type, (Logger, LoggerConfig)> loggers
    Field Value
    Type Description
    Dictionary<Type, ValueTuple<UnityEngine.Logger, LoggerConfig>>

    Methods

    GetLoggerByType(Type)

    Declaration
    public static (Logger logger, LoggerConfig loggerConfig) GetLoggerByType(Type type)
    Parameters
    Type Name Description
    Type type
    Returns
    Type Description
    ValueTuple<UnityEngine.Logger, LoggerConfig>

    GetLoggerByType<T>()

    Declaration
    public static (Logger logger, LoggerConfig loggerConfig) GetLoggerByType<T>()
    Returns
    Type Description
    ValueTuple<UnityEngine.Logger, LoggerConfig>
    Type Parameters
    Name Description
    T

    LogError(Object, String)

    Declaration
    public static void LogError(this Object unityObj, string msg)
    Parameters
    Type Name Description
    UnityEngine.Object unityObj
    String msg

    LogError<T>(String)

    Declaration
    public static void LogError<T>(string msg)
    Parameters
    Type Name Description
    String msg
    Type Parameters
    Name Description
    T

    LogError<T>(Object, String)

    Declaration
    public static void LogError<T>(Object unityObj, string msg)
    Parameters
    Type Name Description
    UnityEngine.Object unityObj
    String msg
    Type Parameters
    Name Description
    T

    LogErrorFormat(Object, String, Object[])

    Declaration
    public static void LogErrorFormat(this Object unityObj, string format, params object[] args)
    Parameters
    Type Name Description
    UnityEngine.Object unityObj
    String format
    Object[] args

    LogErrorFormat<T>(String, Object[])

    Declaration
    public static void LogErrorFormat<T>(string format, params object[] args)
    Parameters
    Type Name Description
    String format
    Object[] args
    Type Parameters
    Name Description
    T

    LogErrorFormat<T>(Object, String, Object[])

    Declaration
    public static void LogErrorFormat<T>(Object unityObj, string format, params object[] args)
    Parameters
    Type Name Description
    UnityEngine.Object unityObj
    String format
    Object[] args
    Type Parameters
    Name Description
    T

    LogLog(Object, String)

    Declaration
    public static void LogLog(this Object unityObj, string msg)
    Parameters
    Type Name Description
    UnityEngine.Object unityObj
    String msg

    LogLog<T>(String)

    Declaration
    public static void LogLog<T>(string msg)
    Parameters
    Type Name Description
    String msg
    Type Parameters
    Name Description
    T

    LogLog<T>(Object, String)

    Declaration
    public static void LogLog<T>(Object unityObj, string msg)
    Parameters
    Type Name Description
    UnityEngine.Object unityObj
    String msg
    Type Parameters
    Name Description
    T

    LogLogFormat(Object, String, Object[])

    Declaration
    public static void LogLogFormat(this Object unityObj, string format, params object[] args)
    Parameters
    Type Name Description
    UnityEngine.Object unityObj
    String format
    Object[] args

    LogLogFormat<T>(String, Object[])

    Declaration
    public static void LogLogFormat<T>(string format, params object[] args)
    Parameters
    Type Name Description
    String format
    Object[] args
    Type Parameters
    Name Description
    T

    LogLogFormat<T>(Object, String, Object[])

    Declaration
    public static void LogLogFormat<T>(Object unityObj, string format, params object[] args)
    Parameters
    Type Name Description
    UnityEngine.Object unityObj
    String format
    Object[] args
    Type Parameters
    Name Description
    T

    LogWarn(Object, String)

    Declaration
    public static void LogWarn(this Object unityObj, string msg)
    Parameters
    Type Name Description
    UnityEngine.Object unityObj
    String msg

    LogWarn<T>(String)

    Declaration
    public static void LogWarn<T>(string msg)
    Parameters
    Type Name Description
    String msg
    Type Parameters
    Name Description
    T

    LogWarn<T>(Object, String)

    Declaration
    public static void LogWarn<T>(Object unityObj, string msg)
    Parameters
    Type Name Description
    UnityEngine.Object unityObj
    String msg
    Type Parameters
    Name Description
    T

    LogWarnFormat(Object, String, Object[])

    Declaration
    public static void LogWarnFormat(this Object unityObj, string format, params object[] args)
    Parameters
    Type Name Description
    UnityEngine.Object unityObj
    String format
    Object[] args

    LogWarnFormat<T>(String, Object[])

    Declaration
    public static void LogWarnFormat<T>(string format, params object[] args)
    Parameters
    Type Name Description
    String format
    Object[] args
    Type Parameters
    Name Description
    T

    LogWarnFormat<T>(Object, String, Object[])

    Declaration
    public static void LogWarnFormat<T>(Object unityObj, string format, params object[] args)
    Parameters
    Type Name Description
    UnityEngine.Object unityObj
    String format
    Object[] args
    Type Parameters
    Name Description
    T
    In This Article
    Back to top Generated by DocFX