Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question How can I prevent the script from appearing in the console?

Discussion in 'Scripting' started by HiForum, May 25, 2024.

  1. HiForum

    HiForum

    Joined:
    Apr 23, 2024
    Posts:
    11
    I have a logger class like this


    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using Object = UnityEngine.Object;
    4.  
    5. namespace iCare.Core {
    6.     public static class CLog {
    7.         static LogLevel _logLevel => CoreSettingsSo.Instance.LogLevel;
    8.  
    9.         public static void Info(string message, Object user = null) {
    10.             if (_logLevel <= LogLevel.Info)
    11.                 Debug.Log($"<color=green>[{DateTime.Now:HH:mm:ss}] [INFO]</color> {message}", user);
    12.         }
    13.  
    14.         public static void Log(string message, Object user = null) {
    15.             if (_logLevel <= LogLevel.Log)
    16.                 Debug.Log($"<color=white>[{DateTime.Now:HH:mm:ss}] [LOG]</color> {message}", user);
    17.         }
    18.  
    19.         public static void Warning(string message, Object user = null) {
    20.             if (_logLevel <= LogLevel.Warning)
    21.                 Debug.LogWarning($"<color=yellow>[{DateTime.Now:HH:mm:ss}] [WARNING]</color> {message}", user);
    22.         }
    23.  
    24.         public static void Error(string message, Object user = null) {
    25.             if (_logLevel <= LogLevel.Error)
    26.                 Debug.LogError($"<color=red>[{DateTime.Now:HH:mm:ss}] [ERROR]</color> {message}", user);
    27.         }
    28.     }
    29. }
    The console always shows the logger class first, followed by the class that gives the real log.

    I don't want to show the logger class on the console at all. I only want to show the class that gives the real log. Is this possible?

    upload_2024-5-25_11-5-15.png
     
  2. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,221
    HiForum and CodeSmile like this.
  3. HiForum

    HiForum

    Joined:
    Apr 23, 2024
    Posts:
    11
    upload_2024-5-25_14-12-26.png
    upload_2024-5-25_14-14-0.png

    Unfortunately it didn't work
     
  4. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    819
    "To hide the marked methods, click the Console menu button then select Strip logging callstack from the menu."

    Did you do that?
     
    HiForum likes this.
  5. HiForum

    HiForum

    Joined:
    Apr 23, 2024
    Posts:
    11
    Oh my bad, i didnt notice that part. Now its working just like i wanted thank you very much both
     
    flashframe likes this.