stratum: allow to reopen wiped global logs

can be useful after a logrotate, to avoid restarting the stratums
This commit is contained in:
Tanguy Pruvot 2018-02-16 13:33:25 +01:00
parent 90e78f772f
commit c99770a5ae

View file

@ -149,7 +149,11 @@ void clientlog(YAAMP_CLIENT *client, const char *format, ...)
if(g_clientlog) if(g_clientlog)
{ {
fprintf(g_clientlog, "%s", buffer3); fprintf(g_clientlog, "%s", buffer3);
fflush(g_clientlog); if (fflush(g_clientlog) == EOF) {
// reopen if wiped
fclose(g_clientlog);
g_clientlog = fopen("client.log", "a");
}
} }
} }
@ -219,7 +223,10 @@ void stratumlog(const char *format, ...)
if(g_stratumlog) if(g_stratumlog)
{ {
fprintf(g_stratumlog, "%s: %s", buffer2, buffer); fprintf(g_stratumlog, "%s: %s", buffer2, buffer);
fflush(g_stratumlog); if (fflush(g_stratumlog) == EOF) {
fclose(g_stratumlog);
g_stratumlog = fopen("stratum.log", "a");
}
} }
} }
@ -264,7 +271,10 @@ void rejectlog(const char *format, ...)
if(g_rejectlog) if(g_rejectlog)
{ {
fprintf(g_rejectlog, "%s: %s", buffer2, buffer); fprintf(g_rejectlog, "%s: %s", buffer2, buffer);
fflush(g_rejectlog); if (fflush(g_rejectlog) == EOF) {
fclose(g_rejectlog);
g_rejectlog = fopen("reject.log", "a");
}
} }
} }