Logging, how do I do that?
I just need a funktion that saves some text like "DirectDraw init - OK" and/or "Shutdown complete"
But the only save to file method I know saves it like many weird ACHII. Can anyone post his/her log funktion? I need a easy to use funktion like AddToLog("bla bla");
I thankful for any help
/MindWipe
"If it doesn''t fit, force it; if it breaks, it needed replacement anyway."
"To some its a six-pack, to me it's a support group."
the easiest way would be file streams
you create the objekt
check if its ok
and store data by using just the << operator
example:
ofstream save(strFileName);
if (save.good())
{
save << somthing << something_else;
}
save.close();
you can save any basic type from int to char
der_meista
you create the objekt
check if its ok
and store data by using just the << operator
example:
ofstream save(strFileName);
if (save.good())
{
save << somthing << something_else;
}
save.close();
you can save any basic type from int to char
der_meista
Have you tried following:
At init:
FILE* log=fopen("mylog.txt","wt");
when at any place
fprintf(log,"DirectDraw init OK\n");
and at end:
fclose(log);
This is more convenient than streams cause you may use expression like:
fprint(log,"%s %d %f",string,intval,floatval);
to print values to log (I found it very useful, and not only I)
Or you programming in Delphi of Visual Basic?
Hope you find it useful
Edited by - nullguid on January 29, 2001 2:48:36 PM
At init:
FILE* log=fopen("mylog.txt","wt");
when at any place
fprintf(log,"DirectDraw init OK\n");
and at end:
fclose(log);
This is more convenient than streams cause you may use expression like:
fprint(log,"%s %d %f",string,intval,floatval);
to print values to log (I found it very useful, and not only I)
Or you programming in Delphi of Visual Basic?
Hope you find it useful
Edited by - nullguid on January 29, 2001 2:48:36 PM
something like this?
I just took this from my leveleditor. had to take some things out, so if somethings wrong, just e-mail me....
cya,
Phil
Uh, btw.. you can use this function just as any format function (just like sscanf, fprintf, printf, an so on)...
Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states![](wink.gif)
Edited by - phueppl1 on January 29, 2001 2:48:17 PM
|
I just took this from my leveleditor. had to take some things out, so if somethings wrong, just e-mail me....
cya,
Phil
Uh, btw.. you can use this function just as any format function (just like sscanf, fprintf, printf, an so on)...
Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states
![](wink.gif)
Edited by - phueppl1 on January 29, 2001 2:48:17 PM
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
nullguid> Yup I''m using C++, I think I''ll use your method. Looks easiest. Thankx.
/MindWipe
"If it doesn''t fit, force it; if it breaks, it needed replacement anyway."
/MindWipe
"If it doesn''t fit, force it; if it breaks, it needed replacement anyway."
"To some its a six-pack, to me it's a support group."
MindWipe, if you use C++ you might want to consider creating a LogFile class and make it a little more robust (support for multiple log files, debug levels for logging, displaying message to output window and/or printer, etc).
BTW, if you are going to log successful function calls (ie, DirectDraw init - OK) I''d recommend against opening/closing your file after every single log. It''ll kill your performance.
- Houdini
BTW, if you are going to log successful function calls (ie, DirectDraw init - OK) I''d recommend against opening/closing your file after every single log. It''ll kill your performance.
- Houdini
- Houdini
I have a logfile class that has everything you talk about Houdini except printer support. How would I go implementing that ?
WHO DO THEY
THINK THEY''RE
FOOLING : YOU ?
GARAL website
WHO DO THEY
THINK THEY''RE
FOOLING : YOU ?
GARAL website
WHO DO THEYTHINK THEY'REFOOLING : YOU ?
BTW im revamping a general logfile and im a little stumped for ideas. Do anyone have suggestions or wishlists for things to be included in a logfile ?
WHO DO THEY
THINK THEY''RE
FOOLING : YOU ?
GARAL website
WHO DO THEY
THINK THEY''RE
FOOLING : YOU ?
GARAL website
WHO DO THEYTHINK THEY'REFOOLING : YOU ?
I would love to see multiple log files supported as well as auto indenting. So if you are like loading a level, you could indent it and show all the portions of the level that loaded... that would be nice
Timestamping would be a nice and easy feature as well.
Spanky
Timestamping would be a nice and easy feature as well.
Spanky
You can also keep a log in RAM, which you''d want to do if you had a drop-down console for users to read as it is updated. You''d also need something like this for a message queue for RPGs or strategy games (conversations for RPGs, commands issued for strategy games). It would be this:
~CGameProgrammer( );
|
~CGameProgrammer( );
~CGameProgrammer( );
Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement