Instead of using basename and doing a strdup etc, just use strrchr because the filepath is going to one of the sources files in zm.

This commit is contained in:
Isaac Connor 2021-02-24 12:23:02 -05:00
parent 099ca9251c
commit 58e3d96f8c
1 changed files with 2 additions and 3 deletions

View File

@ -439,8 +439,8 @@ void Logger::logPrint(bool hex, const char * const filepath, const int line, con
va_list argPtr; va_list argPtr;
struct timeval timeVal; struct timeval timeVal;
char *filecopy = strdup(filepath); const char *base = strrchr(filepath, '/');
const char * const file = basename(filecopy); const char *file = base ? base+1 : filepath;
const char *classString = smCodes[level].c_str(); const char *classString = smCodes[level].c_str();
if ( level < PANIC || level > DEBUG9 ) if ( level < PANIC || level > DEBUG9 )
@ -567,7 +567,6 @@ void Logger::logPrint(bool hex, const char * const filepath, const int line, con
syslog(smSyslogPriorities[level], "%s [%s] [%s]", classString, mId.c_str(), syslogStart); syslog(smSyslogPriorities[level], "%s [%s] [%s]", classString, mId.c_str(), syslogStart);
} }
free(filecopy);
log_mutex.unlock(); log_mutex.unlock();
if ( level <= FATAL ) { if ( level <= FATAL ) {
logTerm(); logTerm();