Ejemplo n.º 1
0
/*----------------------------------------------------------------------*
 * Function: log_write_timestamp                                        *
 * Purpose:  Write a timestamp to the logfile.                          *
 * Params:   newline = 1 to follow timestamp with a newline character.  *
 * Returns:  None.                                                      *
 *----------------------------------------------------------------------*/
void log_write_timestamp(int newline)
{
	char timestring[64];
	log_get_timestamp(timestring);
	if (newline) {
		log_printf("----- %s -----\n", timestring);
	} else {
		log_printf("%s", timestring);
	}
}
Ejemplo n.º 2
0
/*----------------------------------------------------------------------*
 * Function: log_start                                                  *
 * Purpose:  Create a new log file, ready for writing.                  *
 * Params:   filename -> name of log file.                              *
 * Returns:  1 for success, 0 if file couldn't be opened.               *
 *----------------------------------------------------------------------*/
int log_start(char* filename)
{
	int rc = 1;
	FILE *fp;

	if (!filename) {
		rc = 0;
	} else {	
		log_filename = filename;
		fp = fopen(log_filename, "w");

		if (fp) {
			char timestring[64];
			log_get_timestamp(timestring);
			fprintf(fp, "%s Log started\n", timestring);
			fclose(fp);
		} else {
			log_filename = 0;
			rc = 0;
		}
	}
	
	return rc;
}