2016-09-06 11:16:38 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2016-09-06 11:16:38 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2016-09-07 20:29:57 +00:00
|
|
|
#if defined (__APPLE__)
|
2016-09-06 20:25:54 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
|
|
|
|
2016-09-06 11:16:38 +00:00
|
|
|
#include "common.h"
|
2016-09-06 17:44:27 +00:00
|
|
|
#include "types.h"
|
2016-09-14 14:07:24 +00:00
|
|
|
#include "interface.h"
|
2016-09-06 17:44:27 +00:00
|
|
|
#include "timer.h"
|
2016-09-06 11:16:38 +00:00
|
|
|
#include "ext_OpenCL.h"
|
|
|
|
#include "ext_ADL.h"
|
|
|
|
#include "ext_nvapi.h"
|
|
|
|
#include "ext_nvml.h"
|
|
|
|
#include "ext_xnvctrl.h"
|
|
|
|
#include "memory.h"
|
2016-09-06 13:28:56 +00:00
|
|
|
#include "rp_cpu.h"
|
2016-09-06 11:52:26 +00:00
|
|
|
#include "mpsp.h"
|
2016-09-15 14:02:52 +00:00
|
|
|
#include "tuningdb.h"
|
2016-09-20 11:18:47 +00:00
|
|
|
#include "thread.h"
|
2016-09-07 13:13:50 +00:00
|
|
|
#include "opencl.h"
|
2016-09-15 14:02:52 +00:00
|
|
|
#include "hwmon.h"
|
2016-09-07 20:01:34 +00:00
|
|
|
#include "restore.h"
|
2016-09-16 15:01:18 +00:00
|
|
|
#include "hash_management.h"
|
2016-09-10 15:35:58 +00:00
|
|
|
#include "outfile.h"
|
2016-09-09 21:17:43 +00:00
|
|
|
#include "potfile.h"
|
2016-09-13 08:38:59 +00:00
|
|
|
#include "debugfile.h"
|
2016-09-12 12:58:25 +00:00
|
|
|
#include "loopback.h"
|
2016-09-06 11:16:38 +00:00
|
|
|
#include "data.h"
|
|
|
|
#include "logfile.h"
|
|
|
|
|
|
|
|
extern hc_global_data_t data;
|
|
|
|
|
|
|
|
static FILE *logfile_open (char *logfile)
|
|
|
|
{
|
|
|
|
FILE *fp = fopen (logfile, "ab");
|
|
|
|
|
|
|
|
if (fp == NULL)
|
|
|
|
{
|
|
|
|
fp = stdout;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void logfile_close (FILE *fp)
|
|
|
|
{
|
|
|
|
if (fp == stdout) return;
|
|
|
|
|
|
|
|
fclose (fp);
|
|
|
|
}
|
|
|
|
|
2016-09-22 13:30:21 +00:00
|
|
|
void logfile_append (const user_options_t *user_options, const char *fmt, ...)
|
2016-09-06 11:16:38 +00:00
|
|
|
{
|
2016-09-22 13:30:21 +00:00
|
|
|
if (user_options->logfile_disable == true) return;
|
2016-09-06 11:16:38 +00:00
|
|
|
|
|
|
|
FILE *fp = logfile_open (data.logfile);
|
|
|
|
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start (ap, fmt);
|
|
|
|
|
|
|
|
vfprintf (fp, fmt, ap);
|
|
|
|
|
|
|
|
va_end (ap);
|
|
|
|
|
|
|
|
fputc ('\n', fp);
|
|
|
|
|
|
|
|
fflush (fp);
|
|
|
|
|
|
|
|
logfile_close (fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int logfile_generate_id ()
|
|
|
|
{
|
|
|
|
const int n = rand ();
|
|
|
|
|
|
|
|
time_t t;
|
|
|
|
|
|
|
|
time (&t);
|
|
|
|
|
|
|
|
return t + n;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *logfile_generate_topid ()
|
|
|
|
{
|
|
|
|
const int id = logfile_generate_id ();
|
|
|
|
|
|
|
|
char *topid = (char *) mymalloc (1 + 16 + 1);
|
|
|
|
|
|
|
|
snprintf (topid, 1 + 16, "TOP%08x", id);
|
|
|
|
|
|
|
|
return topid;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *logfile_generate_subid ()
|
|
|
|
{
|
|
|
|
const int id = logfile_generate_id ();
|
|
|
|
|
|
|
|
char *subid = (char *) mymalloc (1 + 16 + 1);
|
|
|
|
|
|
|
|
snprintf (subid, 1 + 16, "SUB%08x", id);
|
|
|
|
|
|
|
|
return subid;
|
|
|
|
}
|