Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Extend Console

Discussion in 'Editor Workflows' started by xXApOXx, Nov 7, 2022.

  1. xXApOXx

    xXApOXx

    Joined:
    Feb 9, 2015
    Posts:
    76
    Hi,

    Is it possible to extend the Console?
    I wish to categorize my logs in order to filter them.

    Thx!
     
  2. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,184
    Not really. The Console UI is pretty much closed in this regard. You can simply add tags to your log strings like so:
    "[Network] [Audio] My log message"
    And then use the filter function to search for "[Network]" etc.

    Other than that, there are multiple 3rd party products which implement custom UIs with more advanced category/tag filters. Some of them also use a separate logging system like NLog or implement their own system that work alongside Unity's logger.
     
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,199
    You can replace the logger by using reflection and setting a new value for
    UnityEngine.Debug.s_logger


    Then you can perhaps check the incoming messages or the stack trace or whatever in order to do some logging. You can also format the text before you send them on to the built-in one.
     
  4. xXApOXx

    xXApOXx

    Joined:
    Feb 9, 2015
    Posts:
    76
    For now I have written a file Debug.cs and mirrored every UnityEngine.Debug functions. Doing so, every call to the class Debug is redirected to my file instead of the one from Unity. And I wrote overloads with a category parameter added automatically to the start of message. Finally I have an data with categories to filter and used by my own Debug class to stop or not the logging.

    My plan now is to write my own Console too so instead of stopping logs, the console will use that same data to display or not the logs so they are not completely lost.