mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 23:08:07 +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",
|
OPT_WITH_ARG("--log|-l",
|
||||||
set_int_0_to_9999, opt_show_intval, &opt_log_interval,
|
set_int_0_to_9999, opt_show_intval, &opt_log_interval,
|
||||||
"Interval in seconds between log output"),
|
"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_WITHOUT_ARG("--lowmem",
|
||||||
opt_set_bool, &opt_lowmem,
|
opt_set_bool, &opt_lowmem,
|
||||||
"Minimise caching of shares for low memory applications"),
|
"Minimise caching of shares for low memory applications"),
|
||||||
|
24
logging.c
24
logging.c
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
bool opt_debug = false;
|
bool opt_debug = false;
|
||||||
bool opt_log_output = 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 */
|
/* per default priorities higher than LOG_NOTICE are logged */
|
||||||
int opt_log_level = LOG_NOTICE;
|
int opt_log_level = LOG_NOTICE;
|
||||||
@ -69,6 +71,20 @@ void _applog(int prio, const char *str, bool force)
|
|||||||
const time_t tmp_time = tv.tv_sec;
|
const time_t tmp_time = tv.tv_sec;
|
||||||
tm = localtime(&tmp_time);
|
tm = localtime(&tmp_time);
|
||||||
|
|
||||||
|
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] ",
|
snprintf(datetime, sizeof(datetime), " [%d-%02d-%02d %02d:%02d:%02d] ",
|
||||||
tm->tm_year + 1900,
|
tm->tm_year + 1900,
|
||||||
tm->tm_mon + 1,
|
tm->tm_mon + 1,
|
||||||
@ -76,6 +92,14 @@ void _applog(int prio, const char *str, bool force)
|
|||||||
tm->tm_hour,
|
tm->tm_hour,
|
||||||
tm->tm_min,
|
tm->tm_min,
|
||||||
tm->tm_sec);
|
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 */
|
/* Only output to stderr if it's not going to the screen as well */
|
||||||
if (!isatty(fileno((FILE *)stderr))) {
|
if (!isatty(fileno((FILE *)stderr))) {
|
||||||
|
@ -26,6 +26,8 @@ extern bool want_per_device_stats;
|
|||||||
/* global log_level, messages with lower or equal prio are logged */
|
/* global log_level, messages with lower or equal prio are logged */
|
||||||
extern int opt_log_level;
|
extern int opt_log_level;
|
||||||
|
|
||||||
|
extern int opt_log_dateformat;
|
||||||
|
|
||||||
#define LOGBUFSIZ 256
|
#define LOGBUFSIZ 256
|
||||||
|
|
||||||
extern void _applog(int prio, const char *str, bool force);
|
extern void _applog(int prio, const char *str, bool force);
|
||||||
|
Loading…
Reference in New Issue
Block a user