small cleanup in logging
This commit is contained in:
parent
6d036629d3
commit
48dcb23af0
|
@ -522,8 +522,10 @@ void Logger::logPrint(bool hex, const char * const filepath, const int line, con
|
|||
puts(logString);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
if ( level <= mFileLevel ) {
|
||||
if ( !mLogFileFP ) {
|
||||
// We do this here so that we only create the file if we ever write to it.
|
||||
log_mutex.unlock();
|
||||
openFile();
|
||||
log_mutex.lock();
|
||||
|
@ -535,15 +537,9 @@ void Logger::logPrint(bool hex, const char * const filepath, const int line, con
|
|||
} else {
|
||||
puts("Logging to file, but failed to open it\n");
|
||||
}
|
||||
#if 0
|
||||
} else {
|
||||
printf("Not writing to log file because level %d %s <= mFileLevel %d %s\nstring: %s\n",
|
||||
level, smCodes[level].c_str(), mFileLevel, smCodes[mFileLevel].c_str(), logString);
|
||||
#endif
|
||||
}
|
||||
*syslogEnd = '\0';
|
||||
if ( level <= mDatabaseLevel ) {
|
||||
} // end if level <= mFileLevel
|
||||
|
||||
if ( level <= mDatabaseLevel ) {
|
||||
if ( !db_mutex.trylock() ) {
|
||||
char escapedString[(strlen(syslogStart)*2)+1];
|
||||
mysql_real_escape_string(&dbconn, escapedString, syslogStart, strlen(syslogStart));
|
||||
|
@ -570,29 +566,22 @@ void Logger::logPrint(bool hex, const char * const filepath, const int line, con
|
|||
databaseLevel(tempDatabaseLevel);
|
||||
}
|
||||
db_mutex.unlock();
|
||||
///} else {
|
||||
///Level tempDatabaseLevel = mDatabaseLevel;
|
||||
///databaseLevel(NOLOG);
|
||||
///Error("Can't insert log entry: sql(%s) error(db is locked)", logString);
|
||||
///databaseLevel(tempDatabaseLevel);
|
||||
///}
|
||||
}
|
||||
} // end if level <= mDatabaseLevel
|
||||
|
||||
if ( level <= mSyslogLevel ) {
|
||||
int priority = smSyslogPriorities[level];
|
||||
//priority |= LOG_DAEMON;
|
||||
syslog(priority, "%s [%s] [%s]", classString, mId.c_str(), syslogStart);
|
||||
*syslogEnd = '\0';
|
||||
syslog(smSyslogPriorities[level], "%s [%s] [%s]", classString, mId.c_str(), syslogStart);
|
||||
}
|
||||
|
||||
free(filecopy);
|
||||
if ( level <= FATAL ) {
|
||||
log_mutex.unlock();
|
||||
if ( level <= FATAL ) {
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
if ( level <= PANIC )
|
||||
abort();
|
||||
exit(-1);
|
||||
}
|
||||
log_mutex.unlock();
|
||||
} // end logPrint
|
||||
|
||||
void logInit(const char *name, const Logger::Options &options) {
|
||||
|
|
Loading…
Reference in New Issue