Hi
friends can you send me links OR tell me how to write log files in C++ using events i have got some link from Google but it is not helpful
can anyone please help me with some example code
Hi
friends can you send me links OR tell me how to write log files in C++ using events i have got some link from Google but it is not helpful
can anyone please help me with some example code
Maybe you could be a little more specific?
For example, what sort of log file are you looking to create?
What events?
If you want to write error logs, you can redirect the streambuf of the std::err to
the local file.Then you just write to the std::err with << operators.
actually same as you write to a file.
Are you asking about the exceptions? Then you can set up your SEH routine and
inside that routine you can open the file and just write to it.There is no
magical way.
what eactly do you mean by "using events"? c++ is not event driven.
Well Friends i have to do the testing part so i have to write the log files weather to check there is error or not i hope i am clear
I suppose ther are as many ways to write a logger as there are progammers. The way I did it was to write a funtion that took a const char* as parameter (the message to be logged), open the log file, write out the message, then close the file. Its a very simple function. Then you can call that function as many times in your program as you want to.
If you only want to do the logging when the program is compiled for degging then you might do something like this:
void log(const char* message)
{
#ifdef _DEBUG
// code to log messages go here
#endif
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.