/* * Copyright (C) 2002-2007 The Warp Rogue Team * Part of the Warp Rogue Project * * This software is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License. * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY. * * See the license.txt file for more details. */ /* * Module Name: Log * Description: Log file routines. The log file is used for error reporting * by default, and can be used for debugging purposes if needed. */ #include #define Uses_Util #define Uses_DataFile #include "mheader.h" #include "log.h" /* * log file */ #define FILE_LOG "logfile.txt" /* * deletes the log */ void log_erase(void) { set_data_path(DIR_USER_DATA, FILE_LOG); if (file_exists(data_path())) { remove(data_path()); } } /* * outputs a log message */ void log_output(const char *fmt, ...) { char msg[STRING_BUFFER_SIZE]; va_list vl; FILE *log_file; va_start(vl, fmt); vsprintf(msg, fmt, vl); va_end(vl); set_data_path(DIR_USER_DATA, FILE_LOG); log_file = open_file(data_path(), "a"); fprintf(log_file, "%s\n", msg); close_file(log_file); }