|
-
January 6th, 2002, 03:02 AM
#1
need to know best bethod of Logging.
Hi, can you please suggest me the best method to log the data to a file. For example, in a protocol implementation, when the application is running, we need to log the messages that it receives/transmits. since,after long run the file size get increased so that the performance get affected.
"We are what we repeatedly do.
Excellence then is not an act,
but a habit" - Aristotle
-
January 7th, 2002, 05:26 AM
#2
Re: need to know best bethod of Logging.
My own preference is to use a singleton class. I also prefer to set a logging level in the class.
Then my own preference is to use a sprintf() style of output, and the class itself calls vsprintf() to log. After each write I always flush the buffer. You can also optionally time-stamp but that depends on the nature of the program.
The log level and the timestamp option are class (can be static) members.
However I then use macros to call the class functions, as you can then switch logging off altogether (for release versions etc) simply by modifying the macro, and you don't even need to edit the code to do that - you can simply use a preprocessor define in the _DEBUG but not in the release version.
The best things come to those who rate
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|