Importance of debug.txt
Moderator: Coders of Rage
- cypher1554R
- Chaos Rift Demigod
- Posts: 1124
- Joined: Sun Jun 22, 2008 5:06 pm
Importance of debug.txt
I just want to say that sometimes.. or most of the time, I is dumb as hell.
I spent last 4 days figuring what the heck is wrong with my editor all the sudden working like FDR's legs ( too soon?).
Well anyway.. Today it just came to my upper part of the body (which looks like a head, except there's not much in it) that I should check my debug.txt file, which I worked so hard on to get every detail in most descriptive way out. In just a few seconds I found the bug. It was a messed up -assign- operator that I wrote for Vec3 class.
There. If you don't use this or some other kind of method, you should start right now. Cause after 5000 lines, you is going to be blind as a bat. And I'm not talking about that creepy animal. I'm talking about the fat stick that is used in baseball game.
I spent last 4 days figuring what the heck is wrong with my editor all the sudden working like FDR's legs ( too soon?).
Well anyway.. Today it just came to my upper part of the body (which looks like a head, except there's not much in it) that I should check my debug.txt file, which I worked so hard on to get every detail in most descriptive way out. In just a few seconds I found the bug. It was a messed up -assign- operator that I wrote for Vec3 class.
There. If you don't use this or some other kind of method, you should start right now. Cause after 5000 lines, you is going to be blind as a bat. And I'm not talking about that creepy animal. I'm talking about the fat stick that is used in baseball game.
- trufun202
- Game Developer
- Posts: 1105
- Joined: Sun Sep 21, 2008 12:27 am
- Location: Dallas, TX
- Contact:
Re: Importance of debug.txt
Speaking of debugging with txt files...
A friend and I were having a friendly argument about one of our apps at work. I was trying to prove him wrong, and if a particular error occured, I logged the error and created a file called "KentSucks.txt"
Well..months had gone by and we forgot about this little "feature"... So, we're in the client's office setting up the application. After hours of pounding our heads against the wall, trying to figure out why it's not working - someone on the client side said, "Hey, what's this KentSucks.txt file do!?"
Problem solved!
A friend and I were having a friendly argument about one of our apps at work. I was trying to prove him wrong, and if a particular error occured, I logged the error and created a file called "KentSucks.txt"
Well..months had gone by and we forgot about this little "feature"... So, we're in the client's office setting up the application. After hours of pounding our heads against the wall, trying to figure out why it's not working - someone on the client side said, "Hey, what's this KentSucks.txt file do!?"
Problem solved!
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Importance of debug.txt
I always use some sort of debug when I can't get something to work. If I want it there permanently I use a text file, otherwise I use console output or main()'s return value.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
Re: Importance of debug.txt
I enable debugging via environmental variable. That way I simply change a value before distributing to the team. (my dubug stuff is quite messy, though it's intended for my eyes only. ;P)
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
- aamesxdavid
- ES Beta Backer
- Posts: 347
- Joined: Wed Jan 07, 2009 8:49 pm
- Location: Bellevue, WA
- Contact:
Re: Importance of debug.txt
So I was about to post a new thread in regards to the mention of it in the Adventures videos, but I figured I'd revive an older thread instead.
Falco mentions that the text file they use logs every file the game is trying to access, etc. I was wondering how exactly that was done, and if a similar thing is possible in Python, which is what I'm currently working with. I can write to text files, but the only thing I know of dealing with an error is the "try" and "except" functions in Python. Assuming that every file load doesn't have a "try" (or the C++ equivalent) and individually write to the text file, how is this file written? I don't mind if you only have the C++ answer, as it's more of the programming theory that I'm looking for I suppose. Thanks!
Falco mentions that the text file they use logs every file the game is trying to access, etc. I was wondering how exactly that was done, and if a similar thing is possible in Python, which is what I'm currently working with. I can write to text files, but the only thing I know of dealing with an error is the "try" and "except" functions in Python. Assuming that every file load doesn't have a "try" (or the C++ equivalent) and individually write to the text file, how is this file written? I don't mind if you only have the C++ answer, as it's more of the programming theory that I'm looking for I suppose. Thanks!
- ismetteren
- Chaos Rift Junior
- Posts: 276
- Joined: Mon Jul 21, 2008 4:13 pm
Re: Importance of debug.txt
I dont know how falco handles it, and i dont know how phyton handles files. In C++ a file is represented by a stream (fstream, ifstream of ofstream).
You can create a ifstream(inputStream) object, and then open a file with it(i guees you actully just tells i were to read data from, but i am not sure)
now you can do something like:
To write out witch file the code is accessing, you could have made another file stream before this code, and output the file(as a string(the pathname)) that was being opened(file.txt) to it. If you wanted to know if it was successful i guess you could check if stream hat an valid file open, and output if it (not)hat.
I am not sure if that was what you meant. And sorry for my bad english
You can create a ifstream(inputStream) object, and then open a file with it(i guees you actully just tells i were to read data from, but i am not sure)
Code: Select all
ifstream stream;
stream.open(file.txt);
Code: Select all
//i am not sure if this is correct, but it works atleast very simmilar to this
string txt;
getline(stream, txt);
I am not sure if that was what you meant. And sorry for my bad english
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Importance of debug.txt
I get what you're saying. We have a Debug class (I think it's a singleton) with a function that works like fprintf() does. Debug is initialized like so:aamesxdavid wrote:So I was about to post a new thread in regards to the mention of it in the Adventures videos, but I figured I'd revive an older thread instead.
Falco mentions that the text file they use logs every file the game is trying to access, etc. I was wondering how exactly that was done, and if a similar thing is possible in Python, which is what I'm currently working with. I can write to text files, but the only thing I know of dealing with an error is the "try" and "except" functions in Python. Assuming that every file load doesn't have a "try" (or the C++ equivalent) and individually write to the text file, how is this file written? I don't mind if you only have the C++ answer, as it's more of the programming theory that I'm looking for I suppose. Thanks!
Code: Select all
void Debug::Initialize() {
debugFile,open("debug.txt", ios::out); //Clear the existing file or create a new one
debugFile.close(); //Don't leave it open (we might not actually do this, see end of post)
}
Code: Select all
Debug& debug = Debug::GetInstance();
levelFile.open(filename...);
if (!levelFile) { //there was some sort of error while opening the file
debug.write("Error loading %s\n", filename);
return ERROR; //where error is just some constant or error code or something
}
...
if (!(something = new Something)) {
debug.write("Out of memory!\n");
return ERROR;
}
We just write to it when something doesn't go our way, in other words, and the Debug class handles the file I/O. We don't do anything with exceptions, which is what try { } except { } says to me, but you would basically do the same thing but in your except block instead of with ifs.
Hopefully I answered your question. If you want to see how to do an ellipsis function (replace like %s with an argument, no definite number of arguments passed to the function), I can help you with that. Also, sorry for the ambiguity, I'm too lazy to open the source :D
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- aamesxdavid
- ES Beta Backer
- Posts: 347
- Joined: Wed Jan 07, 2009 8:49 pm
- Location: Bellevue, WA
- Contact:
Re: Importance of debug.txt
Wow, that's awesome, thanks guys! I'll be doing some Python tests with this tonight. This is the kind of stuff I need to work on, because I get the syntax and general flow of things, but I wouldn't have thought to make a class to handle it. Well, I'm a step in the right direction now.
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Importance of debug.txt
Thanks!aamesxdavid wrote:So I was about to post a new thread in regards to the mention of it in the Adventures videos, but I figured I'd revive an older thread instead.
You're welcome =)aamesxdavid wrote:Wow, that's awesome, thanks guys!
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Re: Importance of debug.txt
What's that all about... I don't want to destroy it I want to rule itMarauderIIC wrote:Gyrovorbis wrote:eatcomics could single handedly destroy the universe
But seriously where did that come from???
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Importance of debug.txt
Staff forum. Old post talking about horrible typing =)eatcomics wrote:What's that all about... I don't want to destroy it I want to rule it :mrgreen:MarauderIIC wrote:Gyrovorbis wrote:eatcomics could single handedly destroy the universe
But seriously where did that come from???
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Importance of debug.txt
Yeah, Marauder broke it down pretty much exactly as it is.
And currently (until we're ready for release) the debug output is also wrapped back to the Adventure Log (in game text box) so that we can see our debug output during run time without having to exit out. (That's why there's lots of random numbers outputting sometimes during AiGD videos. Debug is also wrapped to Lua, and that's Peter's cout/printf() equivalent).
And welcome! (though I've seen/talked to you already!)
And currently (until we're ready for release) the debug output is also wrapped back to the Adventure Log (in game text box) so that we can see our debug output during run time without having to exit out. (That's why there's lots of random numbers outputting sometimes during AiGD videos. Debug is also wrapped to Lua, and that's Peter's cout/printf() equivalent).
And welcome! (though I've seen/talked to you already!)
Re: Importance of debug.txt
Ahhhh....MarauderIIC wrote:Staff forum. Old post talking about horrible typing =)eatcomics wrote:What's that all about... I don't want to destroy it I want to rule itMarauderIIC wrote:Gyrovorbis wrote:eatcomics could single handedly destroy the universe
But seriously where did that come from???
Gyrovorbis in those days I could have taken over hell if I wanted to