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.

Script to help with console debugging

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

  1. lurid


    Aug 28, 2005
    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.

    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: