void DebuggerLogger::doLog(const LogEntry* entry) { char buf[LogManager::MAX_BUF_SIZE]; size_t bufSize = sizeof(buf) - 1; if (_lineStart) { int len = formatLog(entry, buf, sizeof(buf)); if (len > 0) OutputDebugStringA(buf); } OutputDebugStringW(Unicode::toUtf16(entry->message, (int)entry->messageLen).c_str()); bool enableErrorLog = false; if (enableErrorLog && entry->logLevel >= LOG_LEVEL_ERROR && entry->srcName && entry->fnName) { int sz = _snprintf(buf, sizeof(buf)-1, " at %s() line %d '%s'", entry->fnName, entry->line, entry->srcName); if (sz > 0) OutputDebugStringA(buf); } if (entry->lineEnd) OutputDebugStringA("\n"); }
virtual void handleRec(const LogRecordPtr& rec) { if (!ignore(rec)) { std::string msg; formatLog(rec, msg); fwrite(msg.c_str(), 1, msg.length(), stdout); if (flushImmediate) { fflush(stdout); } } }
virtual void handleRec(const LogRecordPtr& rec) { if (logfile.isOpen() && !ignore(rec)) { std::string msg; formatLog(rec, msg); hasWriten+= logfile.write(msg.c_str(), msg.length()); if (hasWriten >= flushEvery) { logfile.flush(); hasWriten -= flushEvery; } } }
void writeLog(const char * fileName, const char * funcName, unsigned int line, unsigned int level, const char * format, ...) { va_list ap; if (g_isPrintLog && level >= g_ulLogLevel) { va_start(ap, format); formatLog(format, fileName, funcName, line, level, ap); va_end(ap); } }
void YubiKeyLogger::logConfig(YubiKeyConfig *ykConfig) { //Check if logging is enabled if(!m_enabled) { return; } QFile *file = getLogFile(); if(file == NULL) { return; } QTextStream out(file); QString format = ""; if(m_format == Format_Traditional) { if(m_started) { format += "LOGGING START,{timestampLocal}{endl}"; m_started = false; } format += "{eventType},{timestampLocal},{configSlot},{pubIdTxt},{pvtIdTxt},{secretKeyTxt},{currentAccessCodeTxt},{newAccessCodeTxt},{oathFixedModhex1},{oathFixedModhex2},{oathFixedModhex},{hotpDigits},{oathMovingFactorSeed},{strongPw1},{strongPw2},{sendRef},{chalBtnTrig},{hmacLT64}"; } else if(m_format == Format_Yubico) { format = "{serial},"; if(ykConfig->programmingMode() == YubiKeyConfig::Mode_YubicoOtp) { format += "{pubIdTxt},{pvtIdTxt},"; } else if(ykConfig->programmingMode() == YubiKeyConfig::Mode_OathHotp) { format += "{pubIdTxt},{oathMovingFactorSeed},"; } else if(ykConfig->programmingMode() == YubiKeyConfig::Mode_ChalRespHmac) { format += ",0,"; } else { format += ",,"; } format += "{secretKeyTxt},{newAccessCodeTxt},{timestampFixed},"; } else if(m_format == Format_Flexible) { format = m_flexibleFormat; } else { qDebug() << "unknown format" << m_format; return; } format = formatLog(ykConfig, format); out << format << endl; file->flush(); }
void Logger::printLog(const int level,std::string msg) const { if(level >= _level){ std::cout << formatLog(level,msg) << std::endl; } }