Search Unity

Debug.Log Extensions

Discussion in 'Assets and Asset Store' started by SisusCo, Mar 17, 2020.

  1. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    Hi @yenmoc !

    Do you mean having Debug.Log Extensions get installed under the Packages folder instead of the Assets folder?

    This isn't supported yet by Unity for asset store packages unfortunately - although I did just now find this experimental repo that seems to make it possible...now I am interested in trying it out!
     
  2. yenmoc

    yenmoc

    Joined:
    Sep 21, 2019
    Posts:
    6
    Hi @SisusCo Well, I will try it hope it works, if not sure I will try refactoring
     
  3. LuiBroDood

    LuiBroDood

    Joined:
    Mar 13, 2019
    Posts:
    84
    #1 can i add to Channel.cs the Sisus.Debugging namespace ? without any problems?

    Channel in global namespace interferes with FishNet
    ... hmm even tho fishnet's Channel is in a namespace... weird... idk whats going on lol
    but adding Channel.cs to the Sisus.Debugging makes it have no console reported errors and allows it to Play lol

    #2 also, i can put the whole folder in any folder? i put it in Plugins/1_Docu/Debug.Log Extensions

    is this okay or will something break?

    best console plugin
    thanks
     
  4. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    Hey @LuiBroDood !

    You don't actually have to modify the class manually; the Channel.cs is auto-generated based on the list of channels defined in Project Settings > Debug.Log Extensions.

    In the Project Settings you can uncheck the Replace Default Debug Class option, and then hit the Rebuild Channel Class button and the Channel class will get moved under the Sisus.Debugging namespace.

    Rebuild Channel Class.png

    Yep, this should work without any issues! I gave it a quick test as well and everything looks to be good:

    moved under plugins.png

    Thank you, I'm very glad to hear this! :)
     
  5. Hakim59

    Hakim59

    Joined:
    Nov 14, 2020
    Posts:
    1
    Hello SisusCo

    Very great console, love it.
    Unfortunately I did not find how to resize font size, is there a way? and is it possible to Debug.Watch a variable? like display just 1 message iven if the variable is modificate?

    if you plan to spend time on it can you add the display of class in class with the command Debug.LogState(target)

    Have a good day
     
  6. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    @Hakim59 Awesome to hear you like it, thanks! :)

    Changing font size is not a feature that is currently supported. There is Compact Mode that helps more content fit on screen at the same time, but that's all that can be done at the moment.

    compact-mode.png

    Are you interested in increasing or lowering the font size? I could add in support for customizing it in a future version.


    Debug.LogChanges can be used to log a message to the console every time that the value of a variable changes, and Debug.DisplayOnScreen can be used to pin a variable on screen. There's no functionality to log a message only a single time when the value of a variable changes next. Do you have a use case in mind where logging a message only once would be especially useful?

    Printing out all nested member variables with Debug.LogState is an interested idea! I'll consider adding this in.
     
  7. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    Just bought the package, looked promising.

    Unfortunately...
    upload_2023-3-6_11-23-35.png

    ...the global namespace hack (how does that even work? sounds super useful!) doesn't play well with various official packages I am using in unity 2022.2 :)

    Interestingly, only a few of the packages are affected; URP itself, for instance, isn't, just ShaderGraph and Burst.

    Also, log messages in systems like this one don't get any stack traces, it would be great if they would:

    Code (CSharp):
    1. using Sisus.Debugging;
    2. using Unity.Collections;
    3. using Unity.Entities;
    4. using UnityEngine;
    5.  
    6. namespace Jovian.Systems
    7. {
    8.     [WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]
    9.     [UpdateInGroup(typeof(BakingSystemGroup), OrderLast = true)]
    10.     public partial class DebugBakingSystem : SystemBase
    11.     {
    12.         private EntityQuery _noSectionQuery;
    13.         protected override void OnCreate()
    14.         {
    15.             base.OnCreate();
    16.  
    17.             _noSectionQuery = GetEntityQuery(
    18.                 new EntityQueryDesc
    19.                 {
    20.                     None = new[] {ComponentType.ReadWrite<SceneSection>()},
    21.                     Options = EntityQueryOptions.IncludePrefab | EntityQueryOptions.IncludeDisabledEntities
    22.                 }
    23.             );
    24.  
    25.             RequireForUpdate(_noSectionQuery);
    26.         }
    27.         protected override void OnUpdate()
    28.         {
    29.             if (_noSectionQuery.IsEmpty)
    30.             {
    31.                 return;
    32.             }
    33.             var entities = _noSectionQuery.ToEntityArray(Allocator.TempJob);
    34.             foreach (var entity in entities)
    35.             {
    36.                 Dev.LogWarning($"{EntityManager.GetName(entity)} has no SceneSection!");
    37.             }
    38.             entities.Dispose();
    39.         }
    40.     }
    41. }

    There are also a couple of bugs with the Channel class, it can get out of sync with the list despite the rebuild having been triggered. This is particularly true if you remove your user channel.

    upload_2023-3-6_11-47-15.png

    If you come back later, chances are the settings menu has broken entirely, requiring a reinstall. I have a subtle suspicion this may or may not have something to do with Enter PlayMode Options.

    Edit: no, it seems to be an issue with asset naming during serialization:
    Code (csharp):
    1.  
    2. Main Object Name '' does not match filename 'DebugLogExtensionsProjectSettings'
    3. UnityEngine.StackTraceUtility:ExtractStackTrace ()
    4. Sisus.Debugging.DebugLogExtensionsProjectSettingsProvider:OnSettingChanged () (at Assets/Sisus/Debug.Log Extensions/Scripts/Editor/DebugLogExtensionsProjectSettingsProvider.cs:678)
    5. Sisus.Debugging.DebugLogExtensionsProjectSettingsProvider:DrawChannelsElement (UnityEngine.Rect,int,bool,bool) (at Assets/Sisus/Debug.Log Extensions/Scripts/Editor/DebugLogExtensionsProjectSettingsProvider.cs:520)
    6. UnityEditorInternal.ReorderableList:DoListElements (UnityEngine.Rect,UnityEngine.Rect)
    7. UnityEditorInternal.ReorderableList:DoLayoutList ()
    8. Sisus.Debugging.DebugLogExtensionsProjectSettingsProvider:DrawSettingsGUI () (at Assets/Sisus/Debug.Log Extensions/Scripts/Editor/DebugLogExtensionsProjectSettingsProvider.cs:292)
    9. Sisus.Debugging.DebugLogExtensionsProjectSettingsProvider:DrawSettingsGUI (string) (at Assets/Sisus/Debug.Log Extensions/Scripts/Editor/DebugLogExtensionsProjectSettingsProvider.cs:243)
    10. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    11.  
    Deleting your user channel will trigger this. I don't want the user channel, and I don't want my windows username to be serialized and committed to version cotnrol with ProjectSettings. (this section should go into UserSettings, and even there, I would like a choice to not have the per-user channel)

    There's also a bug with the names going out of sync; (meaning your channels will log as the wrong channels) I suggest using string.GetHashCode() to use a hashtable of unique channel numbers, instead of using indices from 0, and writing these hashcodes into the Channels class.
     
    Last edited: Mar 6, 2023
  8. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    The way it works is really simple: it relies on the fact that if there's a reference to a class named X, and there are multiple classes with the name X, then the compiler will prioritize options found within the same namespace chain with the class containing the reference.
    Code (CSharp):
    1. using UnityEngine; // Priority 3
    2.  
    3. namespace MyNamespace
    4. {
    5.     public class MyClass
    6.     {
    7.         public void MyMethod() => Debug.Log("It works ");
    8.     }
    9.  
    10.     public static class Debug // Priority 1
    11.     {
    12.         public static void Log(string message) => UnityEngine.Debug.Log(message + "like this.");
    13.     }
    14. }
    15.  
    16. public static class Debug // Priority 2
    17. {
    18.     public static void Log(string message) => UnityEngine.Debug.Log(message + "like this.");
    19. }
    20.  
    Since the global namespace is considered the topmost namespace in the namespace chain, all classes in all namespaces will prioritize a Debug class found in the global namespace over the one in the UnityEngine namespace - except for other classes in the UnityEngine namespace.

    Unfortunately:
    1. System.Diagnostics happens to also contain a class named Debug, which has lead to some adding the using alias
    using Debug = UnityEngine.Debug
    to their classes, to help the compiler understand that their Debug class references refer to the one in the UnityEngine namespace in particular.
    2. That particular using alias creates a conflict with a Debug class found in the global namespace.
    3. Since Debug.Log Extensions was initially released, more and more unity packages have been introduced that contain that using alias.

    The end result is that automatically redirecting all Debug.Log calls globally to Debug.Log Extensions' enhanced variants won't be a viable option in most projects today. Not unless you go to the lengths of copying the conflicting packages under the Assets folder, doing a search and replace to remove all the "using Debug = UnityEngine.Debug" references, and then removing the packages from the package manager :confused:

    I'll take a look at this - thanks for letting me know!

    You should be able to turn off the automatic dev personal channel blacklisting in the Project Settings > Debug.Log Extensions.
    Dev.ChannelName.png

    The idea behind the feature is that when working as part of a small team, it could be useful to be able to do some logging that will be very helpful for you to see, but would be probably too spammy for your other team members. By tagging your logging with your personal channel name, the logged messages would only be visible for you by default.
    Code (CSharp):
    1. Dev.Log(Channel.AudioGuy89, Channel.Audio, $"Playing {audioId} in {delay} seconds.", this);
    Code (CSharp):
    1. Dev.Log(Channel.LeetProgrammerGal, Channel.AI, $"AI switching from state {currentState} to {newState}.", this);
    I'll investigate the issues you ran into while trying to delete your dev channel. It looks like something went wrong there when trying to save your Project Settings to disk.

    Your string.GetHashCode suggestion is an interesting idea, but unfortunately GetHashCode results are not guaranteed to be unique, so I couldn't use it as a simple plug-in replacement :( I could use a HashSet<string>, but that would mostly defeat the purpose of the Channel class: avoiding having to perform any string comparisons.
     
    Last edited: Mar 7, 2023
  9. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    Thank you for the detailed reply.

    Regarding hashes - just roll your own. :)

    Code (CSharp):
    1.  public static int GetStableHashCode(this string str)
    2.         {
    3.             unchecked
    4.             {
    5.                 var hash1 = 5381;
    6.                 var hash2 = hash1;
    7.  
    8.                 for (var i = 0; i < str.Length && str[i] != '\0'; i += 2)
    9.                 {
    10.                     hash1 = ((hash1 << 5) + hash1) ^ str[i];
    11.                     if (i == str.Length - 1 || str[i + 1] == '\0')
    12.                         break;
    13.                     hash2 = ((hash2 << 5) + hash2) ^ str[i + 1];
    14.                 }
    15.  
    16.                 return hash1 + (hash2 * 1566083941);
    17.             }
    18.         }
     
  10. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    Even if a hash code is stable it does not guarantee it to be unique for all possible values a string can have.

    For example, only 31 flags can be encoded into an integer bit field before hitting int.MaxValue, and in this case each flag can only have two different values. In a string each character can have ~60 000 different values, so hash collisions are unavoidable.
     
  11. sampenguin

    sampenguin

    Joined:
    Feb 1, 2011
    Posts:
    64
    Love this asset, been using it for some time now. However I'm currently having a problem on iOS and Android devices with Debug.LogIf(), where if the condition is true it still doesn't output to the console. Debug.Log() works fine however.

    Any ideas what could be causing that? I can verify the condition I'm testing against is definitely true on the device.

    UPDATE: same problem on Android.

    I should probably also add that I'm displaying the console in my game via the very nice SRDebugger from the Unity asset store.

    UPDATE 2: Looking at the decompiled code, it looks like there is a
    [Conditional("DEBUG")]
    attribute just above the LogIf methods, which is NOT there on the normal Log calls.

    My "strip log calls from builds" is set to false.

    Up to now, I've been using Dev.* when it's output I don't want to leave the dev environment or for development builds, but I still want the ability to branch on more detailed Debug output in release builds if a problem is encountered, e.g. bugs which can only repro on device.
     
    Last edited: Mar 15, 2023
  12. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    @sampenguin Thank you for reporting this!

    Yeah, it looks like those conditional Conditional attributes are indeed the culprit. They should only be on methods in the Dev class unless strip log calls from builds is enabled. I'll fix this in the next update.
     
  13. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    @sampenguin I've submitted a fix for the LogIf issue to the asset store - and also sent you the fixed package in a PM.
     
  14. sampenguin

    sampenguin

    Joined:
    Feb 1, 2011
    Posts:
    64
    Thanks so much!! I just tried it out and good news, bad news (results from Android only so far):

    Bad news: Still shows same behavior in release builds on device. (Debug.LogIf does NOT output)
    Good news: Development builds now work. (Debug.LogIf DOES output)

    Ideally, Debug.LogIf would still work in release builds, but at least for now I have a way to see more extended output.

    Side note: As a thanks for the speedy reply, I just bought all your other assets. :)
    Thanks for all the good stuff you've put out!
     
  15. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    Hmm, okay I'll take investigate what could be the reason for this.

    And just to make sure: you still don't have the 'Strip Log Calls From Builds' option enabled, right?

    You rock - thanks a bunch :) I hope you find them very useful!
     
  16. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    @sampenguin I found the issue: there was a second set of preprocessor directives that had to be updated, in addition to the ConditionalAttribute, for the code to be executed in release builds. This should be fixed in the new version.
     
    sampenguin likes this.
  17. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    I've now figured out a way to make it possible to reroute all classes to use my enhanced Debug class, but only on specifically hand-picked assemblies.

    In the latest version, I'm tweaking the DLL structure so that the DLLs for different platforms all share the same name.

    Then I've went ahead and disabled the Auto Reference option for the DLLs in the global namespace. This will prevent compile errors from occurring from within package manager packages.

    auto-reference-disabled.png


    Now to change all classes in a particular assembly to use the enhanced Debug class, one just needs to:
    1. Create an Assembly Definition Asset at the folder root, if one doesn't exist already.
    2. Check Override References.
    3. Add Debug-Log-Extensions.dll to the Assembly References list.
    override-references.png


    With this, all classes in the assembly should switch to using the enhanced Debug class without there being any need to manually specify using Debug = Sisus.Debugging.Debug.

    result.png

    I've changed the Channel class from using const fields to static readonly fields in the latest version. Using constants was likely the reason for the channel members mapping to incorrect values when referenced from external assemblies.

    In my testing Console+ was able to properly parse and display stack traces from systems. Could you maybe share the stack trace that wasn't being displayed from the built-in Console?
     
  18. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    What was the literal message and its entire (nonexistent?) stack trace.
     
  19. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    @Thygrrr Right, I get what you mean now; they are missing stack traces when using UnityEngine.Debug.Log as well when the logging takes place in a background thread. I can do some investigating to see if it's something I could remedy. Would you be most interested in getting this information in the editor or in builds?
     
    Last edited: Mar 18, 2023
  20. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    Editor, always Editor. :)
    But don't prioritize it, I'd rather see the basic logging stuff a little more stabilized (and the Context Object feature added to as many of the log overloads as feasible)
     
    SisusCo likes this.
  21. boynet

    boynet

    Joined:
    May 20, 2017
    Posts:
    17
    Hi for some reason I cant get this installed
    after importing I choose yes to make it the default debug
    but it seems like it does nothing
    for example this Debug.Log(() => f); give me error
    error CS1660: Cannot convert lambda expression to type 'object' because it is not a delegate type

    or trying Debug.LogChanges(()=>field)
    error CS0117: 'Debug' does not contain a definition for 'LogChanges'


    if I try to manually using it it still give me error
    using Debug = Sisus.Debugging.Debug;
    error CS0234: The type or namespace name 'Debug' does not exist in the namespace 'Sisus.Debugging' (are you missing an assembly reference?)


    am I missing something?

    the weird thing is I can see the new debug console which confirm me I did import it correctly
    using unity 2021.3.28f1
     
  22. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    Hey @boynet

    Have you tried simply restarting the editor and reinstalling the Debug.Log Extensions package?
    Sometimes compilation issue in Unity can get resolved by doing these things.


    If that doesn't help, then it could also be because you installed Debug.Log Extensions in the global namespace, but this resulted in a compile error in some package you have installed, preventing your project from compiling.

    To fix this issue, you can select the asset
    Sisus > Debug.Log Extensions > Resources > DebugLogExtensionsProjectSettings

    and untick the checkbox
    Use Global Namespace
    .

    DebugLogExtensionsProjectSettings.png

    After scripts have been recompiled, there should no longer be any compile errors, and you should be able to start using Debug.Log extensions in your classes by adding
    using Debug = Sisus.Debugging.Debug;
    to them.

    You can also manually install the package under the
    Sisus.Debugging
    namespace using the unity package
    Sisus > Debug.Log Extensions > Installers > Install In Unique Namespace
    , if that doesn't happen automatically due to the compile errors.

    Installers.png

    Hope this helps!
     
    Last edited: Jul 25, 2023
    boynet likes this.
  23. boynet

    boynet

    Joined:
    May 20, 2017
    Posts:
    17
    Thanks @SisusCo , I just can't get it to work
    I tried removing and re-adding, running the installer, all the things you said

    I have a warning in the console since installing the asset but it seems harmless:

    Unable to find style 'ToolbarSeachCancelButton' in skin 'DarkSkin' Used
    UnityEngine.GUISkin:GetStyle (string)

    Its almost new project I don't have assets installed except yours

    edit:
    the warnning come from the file ConsoleWindowPlusExperimental line 861
     
    Last edited: Jul 25, 2023
  24. santelelle

    santelelle

    Joined:
    Oct 31, 2022
    Posts:
    5
    I am having the same issue, and fixed it by removing the auto reference tick and defining explicitly the assembly references as in the answer from Sisuco from Mar 15
    I need to do this independently if installed using the Global or Unique Namespace.
     
    SisusCo and boynet like this.
  25. boynet

    boynet

    Joined:
    May 20, 2017
    Posts:
    17
    Thanks a lot @santelelle
    I added the Assembly Definition Asset in the root folder and it seems to work now, I didnt find the other setting he referred to disabled the Auto Reference

    but as long as it work I hope its good now
     
    SisusCo likes this.
  26. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    Thank you for the help @santelelle !

    Yeah it does seem like an assembly definition asset is required nowadays in the latest Unity versions, despite Auto Referenced being ticked in the DLL.


    @boynet Thanks for letting me know about the GUIStyle warning, I'll submit an update to fix it.
     
  27. santelelle

    santelelle

    Joined:
    Oct 31, 2022
    Posts:
    5
    @SisusCo I am still struggling to make it work on a bigger project though :( Because if I tick the Override references in the assemply definition file to add Debug-Log-Extension.dll, I then need to manually add all the other references my project needs, which is quite some stuff. And apparently, I need to do this at project level (if I create an additional .asmdef in the plugin folder where I copied the debug-log-extensions plugin with override, and manually add just the references to Debug-Log-Extension.dll, referencing this .asmdef file from the project main .asmdef as GUIDs apparently is not enough).

    If I don't override references, and set the .dlls as Auto Reference, with Global namespace I am getting errors from other assets I have installed (e.g. DOTweens).

    Additionally, I get this error popup for dll in DLL/Debug, does this mean anything?
    upload_2023-7-25_18-0-14.png

    I am using Unity 2021.3.14f1

    I really would like to make this work, as the original console is really annoying, and the channels of your plugin is really what I need :)

    EDIT: I actually got it working with the Unique namespace, just removed the folder and clean reinstalled from the Package Manager (installed manually clicking on the Installers/Install In Unique Namespace). I am fine with the line
    using Debug = Sisus.Debugging.Debug;
    in every script.

    EDIT 2: For the people that are trying these configurations, I suggest to reload unity and your IDE when you want to test something. Because I was getting some errors that just disappeared with reloading both.
     

    Attached Files:

    SisusCo likes this.
  28. santelelle

    santelelle

    Joined:
    Oct 31, 2022
    Posts:
    5
    Quick few other things:
    1) When copying the Debug.log Extensions in another folder (e.g. Plugins/Debug.log Extensions), when double clicking on any of the files in the Debug.log Extensions/Installers, the DLL are created in the root folder of the project (and do not replace the old ones in their current location). Might be an easy fix on your side.
    2) It is not really clear to me if anything changes at all when I tick any of the followings
    upload_2023-7-25_20-6-30.png
    Am I supposed to do something else after setting them?
    3) I also have issues if I delete my username channel from the channel list, as reported by @Thygrrr here https://forum.unity.com/threads/debug-log-extensions.848377/page-2#post-8855158

    PS: I spent few minutes reading all the posts in this thread, crazy work, thank you ;)
     
  29. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    True, that is definitely not optimal... I'll see if it's be possible to automatically move the DLLs to the right place after the unitypackage has been imported.

    You should see an Importing dialog pop open immediately after toggling one of these two options.

    replace-default-debug-class.gif

    Not sure why this wasn't happening for you o_O Perhaps this also broke due to the package being moved under a different folder? I'll need to do some testing to see if this is the case.

    Thanks for letting me know this is reproducible - and reminding me to get it fixed!

    Thank you for the kind words, I hope you'll find it most useful :)
     
  30. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
  31. liulhq

    liulhq

    Joined:
    Dec 22, 2017
    Posts:
    1
    The reason for the error is due to a path error in the Mac system.

    I think this line of code is the main culprit
    Code (CSharp):
    1. if(typeof(Debug).Assembly.Location.StartsWith(Application.dataPath.Replace("/", "\\")))
     
  32. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    Ah right, that makes sense. Thank you for pointing me in the right direction @liulhq !
     
  33. Peeling

    Peeling

    Joined:
    Nov 10, 2013
    Posts:
    443
    Hi - quick question before I buy: does the auto-logging on field change catch it at the instant the field changes and supply a callstack?
     
  34. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    @Peeling Unfortunately no, it'll only detect it at the end of the frame during which the value changed. If you need to get the callstack you still need to add logging for it manually.
     
    Peeling likes this.
  35. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    I have the same issue. More over, i can't use the Sisus.Debugging.Debug at all, the class isn't visible, because it is encapsulated in the Debug-Log-Extensions.dll, which i don't have access to from unity's Assembly-CSharp.dll.

    Any ideas what to do with this? i haven't moved the imported folder, i just import it and that is it. I do not get the dialog, and i can't use the static Debug class.

    Version 1.2.7, Last Updated August 8 2023
     
  36. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    @iSinner You need perform these steps in your project:
    1. Create an Assembly Definition Asset in the folder, under which the scripts in which you want to use Debug.Log Extensions are located.
    2. Tick the
      Override References
      checkbox.
    3. Add
      Debug-Log-Extensions.dll
      to the
      Assembly References
      list.
    4. Click
      Apply
      .
    override-references.png

    After this you have two options:

    Option 1:
    Tick the
    Replace Default Debug Class
    checkbox in
    Project Settings > Debug.Log Extensions
    .

    Project Settings.png

    With this all uses of the Debug class in your scripts will automatically switch to using enhanced version in Debug.Log Extensions.
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class Test : MonoBehaviour
    4. {
    5.     void Start() => Debug.Log("Test");
    6. }
    Option 2:
    Untick the
    Replace Default Debug Class
    checkbox, and use a
    using
    directive to use the Debug class in the
    Sisus.Debugging
    namespace.

    Option 2A:
    Code (CSharp):
    1. using UnityEngine;
    2. using Debug = Sisus.Debugging.Debug;
    3.  
    4. public class Test : MonoBehaviour
    5. {
    6.     void Start() => Debug.Log("Test");
    7. }
    Option 2B:
    Code (CSharp):
    1. using UnityEngine;
    2. using static Sisus.Debugging.Debug;
    3.  
    4. public class Test : MonoBehaviour
    5. {
    6.     void Start() => Log("Test");
    7. }
     
    Last edited: Sep 11, 2023
    iSinner likes this.
  37. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    But i want to use it from Assembly-CSharp, am i out of luck? i don't really want to put my entire project into a root DLL like Assembly-CSharp, just to use the asset.
     
  38. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    If you don't want to use an assembly definition asset, you can also do the following:
    1. Untick the
      Replace Default Debug Class
      checkbox in
      Project Settings > Debug.Log Extensions
      .
    2. Add the following items to the
      Additional Compiler Arguments
      list in
      Project Settings > Player
      :
      1. -r:"Assets\Sisus\Debug.Log Extensions\DLL\Debug\Debug-Log-Extensions.dll"

      2. -r:"Assets\Sisus\Debug.Log Extensions\DLL\Editor\Debug-Log-Extensions.dll"

      3. -r:"Assets\Sisus\Debug.Log Extensions\DLL\Release\Debug-Log-Extensions.dll"
    3. Click
      Apply
      .
    4. Add
      using Debug = Sisus.Debugging.Debug;
      or
      using static Sisus.Debugging.Debug;
      in files where you want to use Debug.Log Extensions.
    additional-compiler-arguments.png
     
    Last edited: Sep 12, 2023
  39. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    It didn't work. The `Sisus.Debugging` namespace still didn't contain the `Debug` class.

    PS btw, the editor DLL has a reference to Settings dll two times, so it gives an error on the first import of the asset. I am removing the duplicate ref by myself, but i think you should fix it on the asset store as well.
     
  40. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    It could be that you just need to restart our IDE after making the changes. You can also try adding
    using Debug = Sisus.Debugging.Debug;
    to a class, saving it, and seeing if it compiles.

    Are you referring to this assembly definition asset?
    DebugLogExtensions.Editor.png

    I didn't see any duplicate entry on my local copy of the latest version. I'll need to redownload it from the package manager and double-check.
     
  41. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    It does compile. But the visual studio says it doesn't exist. So how would i make VS see it? because while it does compile, this can't be worked with in the IDE.

    Also, a question regarding the asset. I am using ECS and i disabled domain reload, but when disabling domain reload, static field cleanup must be handled manually. Does the asset support working with domain reload disabled?
     
  42. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    When something like this happens in Unity it can usually be fixed by going to
    Edit > Preferences... > External Tools
    and pressing the
    Regenerate project files
    button.
    regenerate-project-files.png

    Yes, that is supported :)
     
    iSinner likes this.
  43. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    I did try that, just in case i even restarted the IDE. The Debug class doesn't show up.
    This is amazing. I hope we can sort out the IDE issue so i can start using the asset.

    This compiles

    And i tried with these options(just in case), after closing the IDE, regenerating, and opening the IDE.


    Still doesn't see it in the IDE.
     
    Last edited: Sep 15, 2023
    SisusCo likes this.
  44. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    Hmm... you could check that you have the latest versions of Visual Studio 2022 and the Visual Studio Editor package installed.
    package-manager.png

    If that doesn't help, and it's an option for you, updating to a newer version of Unity could also help. It could be this is happening because of a bug in the Editor that has since been fixed.

    I remember in one project I had to switch to using Visual Studio 2019 for a while, because I had an issue quite similar to what you're describing in the version of Unity we were using at that time.
     
  45. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    I updated the VS Editor package to 2.0.21, the VS 2022 IDE to 17.7.4, Unity to 2022.3.9f1

    Didn't solve the problem.

    What does this do exactly, could you explain?
    Code (CSharp):
    1. -r:"Assets\Sisus\Debug.Log Extensions\DLL\Editor\Debug-Log-Extensions.dll"
    Maybe the VS IDE doesn't have some needed library linked, that's why it doesn't see it? unity doesn't complain because it has access to the code, its linked, but not in the IDE?

    PS also, i tried it in rider, doesn't work either.
     
    Last edited: Sep 18, 2023
  46. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    It's a C# compiler option for adding a reference to an assembly file. Both
    -r:
    and
    -reference:
    should do the same thing.

    Yeah I think that is the issue. But I'm worried that even if we were to add the reference to the project files manually, Unity might remove the changes the next time that the project files are regenerated.

    project - add reference.png

    If you're careful about which options you enable when rebuilding the project files in Unity's preferences, and do some testing to see which ones won't reset the references in project settings, perhaps that could work.
     
    Last edited: Sep 18, 2023
    iSinner likes this.
  47. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    I tried importing the asset on a mac with rider, it didn't see the Debug class as well. But what's interesting, when i added the references in additional compiler arguments, it gave me these errors and didn't compile.

    Code (CSharp):
    1. error CS0006: Metadata file 'Assets\Sisus\Debug.Log Extensions\DLL\Debug\Debug-Log-Extensions.dll' could not be found
    2. error CS0006: Metadata file 'Assets\Sisus\Debug.Log Extensions\DLL\Editor\Debug-Log-Extensions.dll' could not be found
    3. error CS0006: Metadata file 'Assets\Sisus\Debug.Log Extensions\DLL\Release\Debug-Log-Extensions.dll' could not be found
    Not sure why is this different on mac.

    PS previously it was the unity on the win platform.
     
  48. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,331
    Hmm, could be filepaths only work using
    /
    instead of
    \
    on macOS?

    Also, you could try adding a csc.rsp file to your Assets folder, in case that somehow works more reliably than listing the additional compiler arguments in project settings:

    csc.rsp.png

    Csc.rsp file contents:
    Code (csc.rsp):
    1. -r:"Assets/Sisus/Debug.Log Extensions/DLL/Debug/Debug-Log-Extensions.dll"
    2. -r:"Assets/Sisus/Debug.Log Extensions/DLL/Editor/Debug-Log-Extensions.dll"
    3. -r:"Assets/Sisus/Debug.Log Extensions/DLL/Release/Debug-Log-Extensions.dll"
     
    Last edited: Sep 18, 2023
    iSinner likes this.
  49. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    The csc.rsp file solved the issue, both on mac and win. Not only does it link the libraries on both, they now work in IDE as well, the Debug class is visible. Finally!

    Much thanks!
     
    SisusCo likes this.
  50. Tom42_59

    Tom42_59

    Joined:
    Dec 16, 2019
    Posts:
    11
    Hi, Just updated to he latest version, and imported into a new project. Got it setup, but when debugging, the chennel names aren't being coloured, and there is a odd string in the debug console. i have attatched pictures to show.
    upload_2023-10-4_23-11-49.png

    upload_2023-10-4_23-12-14.png

    Whats going on?