/** * All logging goes to the file. Stops syslog logging. * * @param logFilePath [in] - The path of the file to log to. * * @return bool - false if failed to open file. */ bool Logger::LogToFile(const char *logFilePath) { FILE *newFile; LogAutoLock lock(&m_settingsLock, LogAutoLock::Write); if (!logFilePath || !logFilePath[0]) { closeLogFile(); m_logFile = NULL; return true; } if (0 == m_logFilePath.compare(logFilePath)) return true; newFile = ::fopen(logFilePath, "a"); if (!newFile) { char buf[1024]; compat_strerror_r(errno, buf, sizeof(buf)); fprintf(stderr, "Failed to open logfile %s: %s\n", logFilePath, buf); return false; } closeLogFile(); m_logFile = newFile; m_logFilePath = logFilePath; return true; }
const char* SystemErrorToString(int errnum) { int olderr = errno; char *buf = nextFormatMeduimBuffer(); if (!buf) { errno = olderr; return "tls_error"; } compat_strerror_r(errnum, buf, formatMediumBuffersSize); errno = olderr; return buf; }
void Logger::ErrnoError(int errnum, const char *mgs) { char buf[1024]; compat_strerror_r(errnum, buf, sizeof(buf)); LogError("%s: (%d) %s", mgs, errnum, buf); }