aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-05-26 23:38:08 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-06-09 19:23:48 +0100
commit87665281ea6044d313c9b863879758dfea6b9299 (patch)
tree41a0f6bd1b3684ce7007c5b0d35982c6f2087cea /contrib
parentMerge pull request #3340 (diff)
downloadmonero-87665281ea6044d313c9b863879758dfea6b9299.tar.xz
epee: fallback to a counter if gmtime fails when rotating logs
Diffstat (limited to '')
-rw-r--r--contrib/epee/src/mlog.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp
index fb0b4ac2b..0c810729d 100644
--- a/contrib/epee/src/mlog.cpp
+++ b/contrib/epee/src/mlog.cpp
@@ -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;