/*! \brief Open log file * * @param logFileName - Name of log file * @param description - Description written to log file * * @note logging is enabled and timestamp disabled */ void Logging::openLogFile(const char *logFileName, const char *description){ indent = 0; currentName = NULL; if (logFile != NULL) { fclose(logFile); } logFile = openApplicationFile(logFileName, "wt"); #ifdef _WIN32 if (logFile == NULL) { logFile = fopen("C:\\Documents and Settings\\PODonoghue\\Application Data\\usbdm\\xx.log", "wt"); // print("openLogFile() - failed to open %s\n", logFileName); } #endif if (logFile == NULL) { return; } loggingEnabled = true; timestampMode = incremental; getTimeStamp(); fprintf(logFile, "%s - %s, Compiled on %s, %s.\n", description, USBDM_VERSION_STRING, __DATE__,__TIME__); time_t time_now; time(&time_now); fprintf(logFile, "Log file created on: %s" "==============================================\n\n", ctime(&time_now)); }
/*! \brief Open the log file * * @param LogFileName Path of file to open for logging. \n * If NULL a default path is used. */ void openLogFile(const char *logFileName, const char *description){ time_t time_now; if (logFile != NULL) { fclose(logFile); // return; } bool oldLoggingEnabled = loggingEnabled; // Prevent auto log file opening loggingEnabled = false; logFile = openApplicationFile(logFileName, "wt"); loggingEnabled = oldLoggingEnabled; if (logFile == NULL) { logFile = fopen("C:\\Documents and Settings\\PODonoghue\\Application Data\\usbdm\\xx.log", "wt"); // print("openLogFile() - failed to open %s\n", logFileName); } if (logFile == NULL) { return; } print("%s - %s, Compiled on %s, %s.\n", description, USBDM_VERSION_STRING, __DATE__,__TIME__); time(&time_now); print("Log file created on: %s" "==============================================\n\n", ctime(&time_now)); }
/*! \brief Open log file * * @param description - Description written to log file * * @note logging is enabled and timestamp disabled */ void Logging::openLogFile(const char *description) { indent = 0; currentName = NULL; time_t time_now; time(&time_now); if (logFile != NULL) { loggingEnabled = true; fprintf(logFile, "Log re-opened on: %s" "==============================================\n\n", ctime(&time_now)); return; } logFile = openApplicationFile("usbdm.log"); if (logFile == NULL) { return; } loggingEnabled = true; timestampMode = incremental; getTimeStamp(); fprintf(logFile, "%s - %s, Compiled on %s, %s.\n", description, USBDM_VERSION_STRING, __DATE__,__TIME__); fprintf(logFile, "Log file created on: %s" "==============================================\n\n", ctime(&time_now)); // Re-direct stderr to logfile dup2(fileno(logFile), STDERR_FILENO); }
/*! \brief Open the log file * * @param LogFileName Path of file to open for logging. \n * If NULL a default path is used. */ void openLogFile(const char *filename){ time_t time_now; if (logFile != NULL) fclose(logFile); logFile = openApplicationFile(filename); print("%s - %s, Compiled on %s, %s.\n", filename, VERSION_STRING, __DATE__,__TIME__); time(&time_now); print("Log file created on: %s" "==============================================\n\n", ctime(&time_now)); }