Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Script to help with console debugging

Discussion in 'Scripting' started by lurid, Jan 13, 2006.

  1. lurid

    lurid

    Joined:
    Aug 28, 2005
    Posts:
    72
    I'm posting a Python script I wrote to help with Unity console logging/debugging in hopes that it might be of general use to anyone else. Its slightly tailored to the specific way that I'm logging in my own project, but should be easy to modify if you do things differently.

    Functional overview:
    The script opens the Unity application and captures its standard output. It parses out the Unity specific messages so that you see a real-time output similar to the Unity console. If you hit ctrl-c, it kills the script and dumps the full Unity console output for the last 200 lines (including stack traces). It also automatically dumps the most recent full 200 lines if it encounters a System.NullReferenceException in the console.

    You can also tell it to ignore a line which contains a specific string (though it doesn't currently support any kind of regular expressions) in the real-time output. I prefix certain lines in my script with WARNING: or ERROR:, and the script will only print those lines if you tell it to.

    Usage:
    watchMyDebug [warningonly|erroronly|ignore='some string'|ignorefile=somefile]

    Examples (note that you must make this script executable: chmod +x watchMyDebug to run it):

    watchMyDebug warningonly
    will print any lines that start with WARNING: or ERROR:

    watchMyDebug erroronly
    will print any lines that start with ERROR:

    watchMyDebug ignore='Setting rotation to'
    will omit any lines from the real-time output that contain the string 'Setting rotation to', anywhere in the line

    watchMyDebug ignorefile=ignorelines.txt
    will omit any lines from the real-time output that contain strings specified (one per line) in the file ignorelines.txt

    Any lines (the most recent 200) omitted above will still be printed (with a prefix of BUF:) when ctrl-c is typed in the terminal window running the script.

    I can't promise to update this or fix any problems with it due to time constraints, but I'll keep an eye out and do what I can!
     

    Attached Files: