diff --git a/stratum/stratum.cpp b/stratum/stratum.cpp index b868dda..df0e6a7 100644 --- a/stratum/stratum.cpp +++ b/stratum/stratum.cpp @@ -35,6 +35,7 @@ bool g_autoexchange = true; uint64_t g_max_shares = 0; uint64_t g_shares_counter = 0; +uint64_t g_shares_log = 0; time_t g_last_broadcasted = 0; YAAMP_DB *g_db = NULL; @@ -217,7 +218,8 @@ int main(int argc, char **argv) struct rlimit rlim_threads = {0x8000, 0x8000}; setrlimit(RLIMIT_NPROC, &rlim_threads); - stratumlog("* starting stratumd for %s on %s:%d\n", g_current_algo->name, g_tcp_server, g_tcp_port); + stratumlogdate("starting stratum for %s on %s:%d\n", + g_current_algo->name, g_tcp_server, g_tcp_port); g_db = db_connect(); if(!g_db) yaamp_error("Cant connect database"); @@ -308,19 +310,20 @@ void *monitor_thread(void *p) if(g_last_broadcasted + YAAMP_MAXJOBDELAY < time(NULL)) { g_exiting = true; - stratumlog("%s dead lock, exiting...\n", g_current_algo->name); + stratumlogdate("%s dead lock, exiting...\n", g_current_algo->name); exit(1); } if(g_max_shares && g_shares_counter) { - if((g_shares_counter % 5000u) == 0) { - stratumlog("%s %luK shares...\n", g_current_algo->name, (g_shares_counter/10000u)); + if((g_shares_counter - g_shares_log) > 10000) { + stratumlogdate("%s %luK shares...\n", g_current_algo->name, (g_shares_counter/1000u)); + g_shares_log = g_shares_counter; } if(g_shares_counter > g_max_shares) { g_exiting = true; - stratumlog("%s need a restart (%lu shares), exiting...\n", g_current_algo->name, g_max_shares); + stratumlogdate("%s need a restart (%lu shares), exiting...\n", g_current_algo->name, g_max_shares); exit(1); } } diff --git a/stratum/util.cpp b/stratum/util.cpp index bcfec08..e8111ba 100644 --- a/stratum/util.cpp +++ b/stratum/util.cpp @@ -193,6 +193,25 @@ void stratumlog(const char *format, ...) } } +void stratumlogdate(const char *format, ...) +{ + char buffer[YAAMP_SMALLBUFSIZE]; + char date[16]; + va_list args; + time_t rawtime; + struct tm * timeinfo; + + time(&rawtime); + timeinfo = localtime(&rawtime); + strftime(date, 16, "%Y-%m-%d", timeinfo); + + va_start(args, format); + vsprintf(buffer, format, args); + va_end(args); + + stratumlog("%s %s", date, buffer); +} + bool yaamp_error(char const *message) { debuglog("ERROR: %d %s\n", errno, message); diff --git a/stratum/util.h b/stratum/util.h index 60e2262..046e0ad 100644 --- a/stratum/util.h +++ b/stratum/util.h @@ -61,6 +61,7 @@ void initlog(const char *algo); void debuglog(const char *format, ...); void stratumlog(const char *format, ...); +void stratumlogdate(const char *format, ...); void clientlog(YAAMP_CLIENT *client, const char *format, ...); //////////////////////////////////////////////////////////////////////////