diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-05-26 23:38:08 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-06-09 19:23:48 +0100 |
commit | 87665281ea6044d313c9b863879758dfea6b9299 (patch) | |
tree | 41a0f6bd1b3684ce7007c5b0d35982c6f2087cea /contrib/epee/src/mlog.cpp | |
parent | Merge pull request #3340 (diff) | |
download | monero-87665281ea6044d313c9b863879758dfea6b9299.tar.xz |
epee: fallback to a counter if gmtime fails when rotating logs
Diffstat (limited to '')
-rw-r--r-- | contrib/epee/src/mlog.cpp | 3 |
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; |