开发者

How to create Log file for my VS Solution?

开发者 https://www.devze.com 2023-02-26 14:51 出处:网络
I am working on VS 2008. My solution has a lot of projects and each project, a number of source files. I want to log the entry and exit (using fprintf) from the functions inside the source files. How

I am working on VS 2008. My solution has a lot of projects and each project, a number of source files. I want to log the entry and exit (using fprintf) from the functions inside the source files. How do I create a global F开发者_开发问答ILE variable and where do I open (fopen) it in order to accomplish this. I am working on C++.


Take a look at some logging library instead of using plain FILE*. E.g., take a look at list of log4j ports.


Log(char* pString){
    FILE *fp;
    fp = fopen("DataLog.txt", "a");

    if( fp == NULL ){       
        fclose(fp);
    }
    fprintf( fp, "LOG :%s\n", pString );
    fflush(fp);
    fclose(fp); 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号