Browse Source

syslog: allow to set a custom prefix

will allow kopiemtu livecd internal monitor to set it to cpuminer
master
Tanguy Pruvot 10 years ago
parent
commit
d3258d8bcd
  1. 13
      ccminer.cpp

13
ccminer.cpp

@ -192,6 +192,7 @@ bool want_stratum = true;
bool have_stratum = false; bool have_stratum = false;
static bool submit_old = false; static bool submit_old = false;
bool use_syslog = false; bool use_syslog = false;
static char* opt_syslog_pfx = (char*) PACKAGE_NAME;
bool use_colors = true; bool use_colors = true;
static bool opt_background = false; static bool opt_background = false;
bool opt_quiet = false; bool opt_quiet = false;
@ -317,7 +318,8 @@ Options:\n\
#ifdef HAVE_SYSLOG_H #ifdef HAVE_SYSLOG_H
"\ "\
-S, --syslog use system log for output messages\n" -S, --syslog use system log for output messages\n\
--syslog-prefix=... allow to change syslog tool name\n"
#endif #endif
#ifndef WIN32 #ifndef WIN32
"\ "\
@ -366,6 +368,7 @@ static struct option const options[] = {
{ "statsavg", 1, NULL, 'N' }, { "statsavg", 1, NULL, 'N' },
#ifdef HAVE_SYSLOG_H #ifdef HAVE_SYSLOG_H
{ "syslog", 0, NULL, 'S' }, { "syslog", 0, NULL, 'S' },
{ "syslog-prefix", 1, NULL, 1008 },
#endif #endif
{ "threads", 1, NULL, 't' }, { "threads", 1, NULL, 't' },
{ "vote", 1, NULL, 'v' }, { "vote", 1, NULL, 'v' },
@ -992,7 +995,7 @@ static void *miner_thread(void *userdata)
} }
/* Cpu thread affinity */ /* Cpu thread affinity */
if (num_cpus > 1) { if (num_cpus > 1 && opt_n_threads > 1) {
if (!opt_quiet) if (!opt_quiet)
applog(LOG_DEBUG, "Binding thread %d to cpu %d", thr_id, applog(LOG_DEBUG, "Binding thread %d to cpu %d", thr_id,
thr_id % num_cpus); thr_id % num_cpus);
@ -1866,7 +1869,11 @@ static void parse_arg(int key, char *arg)
want_stratum = false; want_stratum = false;
break; break;
case 'S': case 'S':
case 1008:
applog(LOG_INFO, "Now logging to syslog...");
use_syslog = true; use_syslog = true;
if (arg && strlen(arg))
opt_syslog_pfx = strdup(arg);
break; break;
case 'd': // CB case 'd': // CB
{ {
@ -2135,7 +2142,7 @@ int main(int argc, char *argv[])
#ifdef HAVE_SYSLOG_H #ifdef HAVE_SYSLOG_H
if (use_syslog) if (use_syslog)
openlog(PACKAGE_NAME, LOG_PID, LOG_USER); openlog(opt_syslog_pfx, LOG_PID, LOG_USER);
#endif #endif
work_restart = (struct work_restart *)calloc(opt_n_threads, sizeof(*work_restart)); work_restart = (struct work_restart *)calloc(opt_n_threads, sizeof(*work_restart));

Loading…
Cancel
Save