mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 14:58:01 +00:00
log: Added a switch to the log date and time format.
It is possible to switch back to full date and time on each log line with "--log-dateformat 1". The short time-only format is default with the value of 0. Log with short time-only format looks like: [23:59:59] Accepted 389c47d1 Diff 1.16K/512 GPU 0 pool 0 [00:00:16] Log date is now 2013-12-22 [00:00:16] Stratum from pool 0 detected new block [00:00:33] Accepted 7a4950a4 Diff 536/512 GPU 0 pool 0
This commit is contained in:
parent
fd8d465b02
commit
ba1c47781f
@ -1078,6 +1078,9 @@ static struct opt_table opt_config_table[] = {
|
||||
OPT_WITH_ARG("--log|-l",
|
||||
set_int_0_to_9999, opt_show_intval, &opt_log_interval,
|
||||
"Interval in seconds between log output"),
|
||||
OPT_WITH_ARG("--log-dateformat",
|
||||
set_int_0_to_10, opt_show_intval, &opt_log_dateformat,
|
||||
"Set log dateformat (0 or 1) - 0 is time only, 1 is full date and time."),
|
||||
OPT_WITHOUT_ARG("--lowmem",
|
||||
opt_set_bool, &opt_lowmem,
|
||||
"Minimise caching of shares for low memory applications"),
|
||||
|
38
logging.c
38
logging.c
@ -17,6 +17,8 @@
|
||||
|
||||
bool opt_debug = false;
|
||||
bool opt_log_output = false;
|
||||
int last_date_output_day = 0;
|
||||
int opt_log_dateformat = 0;
|
||||
|
||||
/* per default priorities higher than LOG_NOTICE are logged */
|
||||
int opt_log_level = LOG_NOTICE;
|
||||
@ -69,13 +71,35 @@ void _applog(int prio, const char *str, bool force)
|
||||
const time_t tmp_time = tv.tv_sec;
|
||||
tm = localtime(&tmp_time);
|
||||
|
||||
snprintf(datetime, sizeof(datetime), " [%d-%02d-%02d %02d:%02d:%02d] ",
|
||||
tm->tm_year + 1900,
|
||||
tm->tm_mon + 1,
|
||||
tm->tm_mday,
|
||||
tm->tm_hour,
|
||||
tm->tm_min,
|
||||
tm->tm_sec);
|
||||
if ((opt_log_dateformat == 0) && (last_date_output_day != tm->tm_mday))
|
||||
{
|
||||
last_date_output_day = tm->tm_mday;
|
||||
char date_output_str[64];
|
||||
snprintf(date_output_str, sizeof(date_output_str), "Log date is now %d-%02d-%02d",
|
||||
tm->tm_year + 1900,
|
||||
tm->tm_mon + 1,
|
||||
tm->tm_mday);
|
||||
_applog(prio, date_output_str, force);
|
||||
|
||||
}
|
||||
|
||||
if (opt_log_dateformat == 1)
|
||||
{
|
||||
snprintf(datetime, sizeof(datetime), " [%d-%02d-%02d %02d:%02d:%02d] ",
|
||||
tm->tm_year + 1900,
|
||||
tm->tm_mon + 1,
|
||||
tm->tm_mday,
|
||||
tm->tm_hour,
|
||||
tm->tm_min,
|
||||
tm->tm_sec);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(datetime, sizeof(datetime), " [%02d:%02d:%02d] ",
|
||||
tm->tm_hour,
|
||||
tm->tm_min,
|
||||
tm->tm_sec);
|
||||
}
|
||||
|
||||
/* Only output to stderr if it's not going to the screen as well */
|
||||
if (!isatty(fileno((FILE *)stderr))) {
|
||||
|
Loading…
Reference in New Issue
Block a user