C/C++ Log function source code

// log error info to file.
void Log(char *szInfo, ...)
{
    va_list args = NULL;
    FILE *fp = NULL;

    if (NULL == szInfo) {
        return;
    }

    fp = fopen("ad.log", "a+");
    if (NULL == fp) {
        return;
    }
    //format log information.
    va_start(args, szInfo);
    (void)vfprintf(fp, (const char *)szInfo, args);
    va_end(args);

    (void)fclose(fp);
    return;
}

你可能感兴趣的:(C/C++ Log function source code)