Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Scripting different "stack trace logging" on each debug channel ?

Discussion in '5.2 Beta' started by jojo665_, Jul 15, 2015.

  1. jojo665_

    jojo665_

    Joined:
    Feb 16, 2014
    Posts:
    4
    hi

    the new "stack trace logging" level look great, but can it be apply differently to each Debug.Log* channel ?

    for example, it is almost not useful to get C#/script stack for Debug.Log(); but a C#/script stack trace is wanted for Debug.LogError()...

    thanks
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,875
    Hey,

    working is being done in that area, not sure if it will be available for 5.2, though. But if you're really want such functionality now, you can implement it yourself by writing a custom logger.

    something like this:

    Code (csharp):
    1.  
    2. class Logger
    3. {
    4.     public void Log(string msg)
    5.     {
    6.        Application.stacktraceLogType = StackTraceLogType.None;
    7.        Debug.Log(msg);
    8.     }  
    9.     public void LogError(string msg)
    10.     {
    11.        Application.stacktraceLogType = StackTraceLogType.Full;
    12.        Debug.LogError(msg);
    13.     }
    14. }
    15.  
     
  3. jojo665_

    jojo665_

    Joined:
    Feb 16, 2014
    Posts:
    4
    we have a similar solution for 4.x, however, we lost the ability to double click on console and able to have VS/MD jump directly to the error line.... which is not ideal
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,875
    It's a known issue, we have a bug regarding this,.
     
  5. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    It would be cool if we could place an attribute above a method to skip that method when we double click on the log via the console.

    The only way to do it right now is to compile your code in to a DLL. In the console, if you double click on any log's made from inside a DLL you will be taken to the line in your project where you made the call to that DLL method.

    I can see it being handy in a lot of cases. For example, if I write a Unity plugins that, say, loads the contents of some file, I could log an error in the Load method of my plugin if the file doesn't exist. This Load method could have that attribute above it and when the user clicks on the error in the console ("File not found"), they would be taken to the line where they called the Load function.

    *shrug* just a quick idea off the top of my head, might need some fleshing out.
     
  6. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Hey there,
    Im sondering what the status on this is. I really love this feature, but without being able to specify it per channel its not that useful. In general fixing that custom logging functions work terriblly would be great. Thanks :)