Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Logging methods

Author
Message
Bishop
21
Years of Service
User Offline
Joined: 18th Dec 2002
Location: In my favorite chair...
Posted: 8th Nov 2008 07:39 Edited at: 8th Nov 2008 07:41
Heya lads!

Am starting a new project and trying to be really organized. So, before jumping in with all the fun stuff, I am writing is piece by piece, module by module, starting with a simple logging system to keep track of what's going on!

However, I am having trouble with outputting the file. I can get the textfile open and whatnot and even enter an error with a timestamp, but it only holds a single log entry. I was hoping to have a compiled entry, like adding a new line for every entry. Here is the basic code right now;



I stripped out all the other stuff so you can see the barebone basics =D

Anyhow, if anyone knows how to just add a line to the log, rather than replacing the entire text file, I would appreciate the help!

Thanks!
Bishop


Tux is my guildmaster.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th Nov 2008 13:27 Edited at: 8th Nov 2008 13:33
Use the constructor to open your file, use addEntry to write, then if necessary, use the destructor to close the file (not necessary in your case).

You might also want to add an option to force flushing to the file for every line written, or else a crash could leave the back end of the file unwritten in a temporary file buffer somewhere.

[EDIT]
Actually, I coded this last night for another purpose, and I've hacked it to match what I suggested:


Sorry, but I used C-style file I/O.

Bishop
21
Years of Service
User Offline
Joined: 18th Dec 2002
Location: In my favorite chair...
Posted: 9th Nov 2008 11:03
Thanks for the code! I appreciate the help.

Looking into the problem further. The c-style input seems...easier than c++.

Thanks!


Tux is my guildmaster.

Login to post a reply

Server time is: 2024-09-30 09:30:04
Your offset time is: 2024-09-30 09:30:04