Skip to content
Snippets Groups Projects
Commit 6df88451 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Use timestr() instead of ctime_r() for logging full date/times

Also when detecting a blocked event_thread, log the event_code that is/was
running last.
parent 4ff6bcde
No related branches found
No related tags found
No related merge requests found
Pipeline #7155 passed
...@@ -3249,7 +3249,7 @@ void event_thread(void* arg) ...@@ -3249,7 +3249,7 @@ void event_thread(void* arg)
sbbs->lprintf(LOG_INFO,"Waiting for node %d to run timed event: %s" sbbs->lprintf(LOG_INFO,"Waiting for node %d to run timed event: %s"
,sbbs->cfg.event[i]->node, event_code); ,sbbs->cfg.event[i]->node, event_code);
sbbs->lprintf(LOG_DEBUG,"event last run: %s (0x%08x)" sbbs->lprintf(LOG_DEBUG,"event last run: %s (0x%08x)"
,timestr(&sbbs->cfg, sbbs->cfg.event[i]->last, str) ,sbbs->timestr(sbbs->cfg.event[i]->last)
,sbbs->cfg.event[i]->last); ,sbbs->cfg.event[i]->last);
lastnodechk=0; /* really last event time check */ lastnodechk=0; /* really last event time check */
start=time(NULL); start=time(NULL);
...@@ -3517,7 +3517,6 @@ sbbs_t::sbbs_t(ushort node_num, union xp_sockaddr *addr, size_t addr_len, const ...@@ -3517,7 +3517,6 @@ sbbs_t::sbbs_t(ushort node_num, union xp_sockaddr *addr, size_t addr_len, const
bool sbbs_t::init() bool sbbs_t::init()
{ {
char str[MAX_PATH+1]; char str[MAX_PATH+1];
char tmp[128];
int result; int result;
int i,j,k,l; int i,j,k,l;
node_t node; node_t node;
...@@ -3622,8 +3621,8 @@ bool sbbs_t::init() ...@@ -3622,8 +3621,8 @@ bool sbbs_t::init()
log(crlf); log(crlf);
time_t ftime = fdate(str); time_t ftime = fdate(str);
safe_snprintf(str,sizeof(str), safe_snprintf(str,sizeof(str),
"End of preexisting log entry (possible crash on %.24s)" "End of preexisting log entry (possible crash on %s)"
,ctime_r(&ftime, tmp)); ,timestr(ftime));
logline(LOG_NOTICE,"L!",str); logline(LOG_NOTICE,"L!",str);
log(crlf); log(crlf);
catsyslog(true); catsyslog(true);
...@@ -4303,9 +4302,8 @@ void sbbs_t::logoffstats() ...@@ -4303,9 +4302,8 @@ void sbbs_t::logoffstats()
now = time(NULL); now = time(NULL);
if(now <= logontime) { if(now <= logontime) {
char tmp[128];
lprintf(LOG_WARNING, "Logoff time (%u) <= logon time (%u): %s" lprintf(LOG_WARNING, "Logoff time (%u) <= logon time (%u): %s"
,(uint)now, (uint)logontime, ctime_r(&logontime, tmp)); ,(uint)now, (uint)logontime, timestr(logontime));
return; return;
} }
uint minutes_used = (uint)(now-logontime)/60; uint minutes_used = (uint)(now-logontime)/60;
...@@ -5379,7 +5377,11 @@ NO_SSH: ...@@ -5379,7 +5377,11 @@ NO_SSH:
t = event_thread_tick; t = event_thread_tick;
if(now > t && now - t > 60 * 60 * 2) { if(now > t && now - t > 60 * 60 * 2) {
if(!event_thread_blocked) { if(!event_thread_blocked) {
lprintf(LOG_ERR, "Event thread appears to be blocked since %.24s", ctime_r(&t, str)); if(*events->event_code != '\0')
snprintf(str, sizeof str, " running %s", events->event_code);
else
*str = '\0';
lprintf(LOG_ERR, "Event thread appears to be blocked%s since %s", str, events->timestr(t));
event_thread_blocked = true; event_thread_blocked = true;
} }
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment