mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 12:09:54 +00:00
epee: fallback to a counter if gmtime fails when rotating logs
This commit is contained in:
parent
25e7a7d96f
commit
87665281ea
1 changed files with 2 additions and 1 deletions
|
@ -47,6 +47,7 @@ using namespace epee;
|
|||
static std::string generate_log_filename(const char *base)
|
||||
{
|
||||
std::string filename(base);
|
||||
static unsigned int fallback_counter = 0;
|
||||
char tmp[200];
|
||||
struct tm tm;
|
||||
time_t now = time(NULL);
|
||||
|
@ -56,7 +57,7 @@ static std::string generate_log_filename(const char *base)
|
|||
#else
|
||||
(!gmtime_r(&now, &tm))
|
||||
#endif
|
||||
strcpy(tmp, "unknown");
|
||||
snprintf(tmp, sizeof(tmp), "part-%u", ++fallback_counter);
|
||||
else
|
||||
strftime(tmp, sizeof(tmp), "%Y-%m-%d-%H-%M-%S", &tm);
|
||||
tmp[sizeof(tmp) - 1] = 0;
|
||||
|
|
Loading…
Reference in a new issue