mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-23 07:38:53 +00:00
Merge pull request #3972
8766528
epee: fallback to a counter if gmtime fails when rotating logs (moneromooo-monero)
This commit is contained in:
commit
c0c6102260
@ -47,6 +47,7 @@ using namespace epee;
|
|||||||
static std::string generate_log_filename(const char *base)
|
static std::string generate_log_filename(const char *base)
|
||||||
{
|
{
|
||||||
std::string filename(base);
|
std::string filename(base);
|
||||||
|
static unsigned int fallback_counter = 0;
|
||||||
char tmp[200];
|
char tmp[200];
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
@ -56,7 +57,7 @@ static std::string generate_log_filename(const char *base)
|
|||||||
#else
|
#else
|
||||||
(!gmtime_r(&now, &tm))
|
(!gmtime_r(&now, &tm))
|
||||||
#endif
|
#endif
|
||||||
strcpy(tmp, "unknown");
|
snprintf(tmp, sizeof(tmp), "part-%u", ++fallback_counter);
|
||||||
else
|
else
|
||||||
strftime(tmp, sizeof(tmp), "%Y-%m-%d-%H-%M-%S", &tm);
|
strftime(tmp, sizeof(tmp), "%Y-%m-%d-%H-%M-%S", &tm);
|
||||||
tmp[sizeof(tmp) - 1] = 0;
|
tmp[sizeof(tmp) - 1] = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user