C ++ basic accumulation-Log Files

Source: Internet
Author: User

InProgramDuring debugging, printing logs is very helpful for tracking problems during development, although there are many encapsulated log classes. However, if it is a simple application, the following simple function can output log files.

Static void savelog (char * C)

{
Ctime TM = ctime: getcurrenttime ();
Cstring name;
Name. Format (_ T ("C: \ log _ % d. log"), TM. getmonth (), TM. getday ());
Cfile file;
If (! File. Open (name, cfile: modereadwrite ))
{
File. Open (name, cfile: modecreate | cfile: modereadwrite );
}
File. seektoend ();
File. Write (C, 1 );
File. Close ();

}

of course, we can place it in the CPP file of each module in a project, you can change the log output file name to track the log files of each module.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.