Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Bug How about getting HideInCallstack to work right?

Discussion in 'Editor & General Support' started by aybe, Apr 22, 2023.

  1. aybe


    Feb 20, 2019
    Suppose that you have the following method to relieve you from typing source and context over and over:

    Code (CSharp):
    1.     public static class ObjectExtensions
    2.     {
    3.         [HideInCallstack]
    4.         public static void Log(this Object source, LogType logType, object message, Object? context = null)
    5.         {
    6.             Debug.unityLogger.Log(logType, source.GetType().Name, message, context ? context : source);
    7.         }
    8.     }
    While this does work, the Unity console is terribly stupid; when you double-click the log entry, it will open that very method on your IDE which kind of defeats the purpose of Strip logging callstack setting.

    From usability standpoint, it would make a lot of sense that, when double-clicking a log entry that it opens the actual method where that message was logged in first instance, and not another method; don't you agree? :)
  2. MoonMoritz


    Jan 30, 2022
    Actually it doesn't work at all for me anymore (2022.2.18f1) :(
    Last edited: May 13, 2023
    DF3Boris likes this.
  3. PcGameHunter


    Sep 16, 2019
    Just encountered this as well in the 2022 LTS, pretty disappointed. I thought the main use-case would be wrapper classes for logging, json, etc...
    The option in the console settings for "Strip logging calls" seemed broken until I toggled it on and off and restarted the editor.
  4. Thygrrr


    Sep 23, 2013
    Reported as IN-49697.

    I wrote a logging solution and realized how broken this attribute is - it doesn't work at all anymore in 2022.3 LTS.
  5. NuclearCookieTF


    Mar 29, 2021
    Was hoping for the same behaviour as well.
  6. Theromanek100


    Jun 23, 2016
    I've been writing my own log wrapper for my new project, and this problem bothered me a lot. I've found a solution, though it would be nice if Unity added this functionality to the attribute because it makes sense that the double click would move to the top line from the call stack that is visible in the console, not just hide the text.

    Anyway, the solution that might work very well depending on the structure of your project is to make your log wrapper into a non-static class with additional logic for your logs and then call functions on the instance of this class.

    I've base classes for both MonoBehaviours and SO so in my case I just needed to write one line in each of those files to have all of the existing logs in my project use my custom system:

    Code (CSharp):
    1. public abstract class RSMonoBehaviour : SerializedMonoBehaviour
    2. {
    3.     protected RSLogger Debug { get; } = new RSLogger();
    4. }
    RSLogger has the same functions as the default Unity logger with some additional, optional parameters, and because the name of the property is the same as Unity's class the usage looks exactly the same as in the default logger.
    MoonMoritz likes this.