Пример #1
0
void LOCACC::writeHtmlLogFile(QJsonArray logArray)
{
    QString logText = "<html><head><title>"+ getInteractivityName() +
            "</title></head><body><h1 style='text-align:center;'>Replacement Log for " + getInteractivityName() +"</h1>"
            "<table border='1' style='text-align: center;margin: auto'>"
            "<thead style='font-weight: bold;'><td>Screen</td><td>Element</td><td>Message</td><td>LOC Text</td><td>CommonId</td></thead>";
    for(int i = 0 ; i < logArray.count() ; i++)
    {
        QJsonObject obj = logArray.at(i).toObject();
        logText += "<tr><td>" + obj["screenId"].toString()
                     + "</td><td>" + obj["elementId"].toString()
                     + "</td><td>" + obj["messageId"].toString()
                     + "</td><td>" + obj["originalText"].toString()
                     + "</td><td>" + obj["commonId"].toString()
                     + "</td></tr>";
    }
    logText += "</table><h1 style='text-align:center;'>Total changes :" + QString::number(logArray.count()) + "</body></html>";

    QString str_htmlFilePath = getLogFilePath() + ".htm";
    QFile htmlLogFile(str_htmlFilePath);
    htmlLogFile.remove();
    htmlLogFile.open(QIODevice::ReadWrite | QIODevice::Text);
    QTextStream out(&htmlLogFile);
    out << logText;
    htmlLogFile.close();    
    QDesktopServices::openUrl(QUrl(str_htmlFilePath.replace("\\","/")));
}
Пример #2
0
unsigned int LogSettings::getLogFileSize()
{
    if(!isLogToFile())
    {
        return 0;
    }
    return common::CRhoFile::getFileSize(getLogFilePath().c_str());
}
Пример #3
0
int EDB_KRCB::init(pmdOptions *options)
{
	setDBStatus(EDB_DB_NORMAL);
	setDataFilePath(options->getDBPath());
	setLogFilePath(options->getLogPath());
	strncpy(_pdDiagLogPath, getLogFilePath(), sizeof(_pdDiagLogPath));
	setSvcName(options->getServiceName());
	setMaxPool(options->getMaxPool());
	return _rtnMgr.rtnInitialize();
}	
Пример #4
0
void LogSettings::saveToFile(){
    RHOCONF().setInt("MinSeverity", getMinSeverity(), true );
    RHOCONF().setBool("LogToOutput", isLogToOutput(), true );
    RHOCONF().setBool("LogToFile", isLogToFile(), true );
#if !defined(OS_MACOSX) 
    RHOCONF().setString("LogFilePath", getLogFilePath(), true );
#endif
    RHOCONF().setInt("MaxLogFileSize", getMaxLogFileSize(), true );
    RHOCONF().setString("LogCategories", getEnabledCategories(), true );
    RHOCONF().setString("ExcludeLogCategories", getDisabledCategories(), true );
}
Пример #5
0
void LogSettings::getLogText(String& strText)
{
    boolean bOldSaveToFile = isLogToFile();
    setLogToFile(false);

    common::CRhoFile oFile;
    if ( oFile.open( getLogFilePath().c_str(), common::CRhoFile::OpenReadOnly) )
        oFile.readString(strText);

    setLogToFile(bOldSaveToFile);
}
Пример #6
0
void Manager::saveLogsToFile() const
{
    createLogFolder();
    ofstream output(getLogFilePath().c_str(), fstream::out);
    output << amountAccounts << endl << endl;
    for (int i = 0; i < amountAccounts; ++i)
    {
        output << (*account[i]) << endl;
    }
    output.close();
}
Пример #7
0
void LOCACC::writeLogFile(QJsonArray logArray)
{
    QJsonObject jObject;
    jObject.insert("logEntries",logArray);

    QFile logFile(getLogFilePath() + ".log");
    logFile.remove();
    logFile.open(QIODevice::ReadWrite | QIODevice::Text);    

    QJsonDocument doc(jObject);
    logFile.write(doc.toJson());
    logFile.close();
}
Пример #8
0
LogTab::LogTab(QWidget *parent)
    : QWidget(parent)
{
    isLogMsgCheckBox = new QCheckBox(tr("Enable log message"));
    if (Global::preferences->isLogMsg) {
        isLogMsgCheckBox->setCheckState(Qt::Checked);
    }
    noLogLockMsgBeforeOpenCheckBox
        = new QCheckBox(tr("Not log lock message before open"));
    noLogLockMsgBeforeOpenCheckBox->setEnabled(false);
    if (Global::preferences->noLogLockMsgBeforeOpen) {
        noLogLockMsgBeforeOpenCheckBox->setCheckState(Qt::Unchecked);
    }
    isLogLoginNameCheckBox = new QCheckBox(tr("Log nickname and login name"));
    if (Global::preferences->isLogLoginName) {
        isLogLoginNameCheckBox->setCheckState(Qt::Checked);
    }
    isLogIPCheckBox = new QCheckBox(tr("Log ip address"));
    if (Global::preferences->isLogIP) {
        isLogIPCheckBox->setCheckState(Qt::Checked);
    }

    logFileButton = new QPushButton(tr("Log File"));
    logFileLabel = new QLabel;
    int frameStyle = QFrame::Sunken | QFrame::Panel;
    logFileLabel->setFrameStyle(frameStyle);
    logFileLabel->setText(Global::preferences->logFilePath);

    connect(logFileButton, SIGNAL(clicked()),
            this, SLOT(getLogFilePath()));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(isLogMsgCheckBox);
    mainLayout->addWidget(noLogLockMsgBeforeOpenCheckBox);
    mainLayout->addWidget(isLogLoginNameCheckBox);
    mainLayout->addWidget(isLogIPCheckBox);

    QGridLayout *layout = new QGridLayout;
    layout->addWidget(logFileButton, 0, 0);
    layout->addWidget(logFileLabel, 0, 1);
    layout->setColumnStretch(0, 10);
    layout->setColumnStretch(1, 30);

    mainLayout->addLayout(layout);

    setLayout(mainLayout);
}
Пример #9
0
void Manager::loadLogsFromFile()
{
    ifstream input;
    input.open(getLogFilePath().c_str());
    input >> amountAccounts;
    for (int i = 0; i < amountAccounts; ++i)
    {
        Account *tempAccount = new Account;
        input >> (*tempAccount);
        account.push_back(tempAccount);
        ID.push_back(tempAccount->getID());
    }
    if (input.is_open())
    {
        input.close();
    }
}
Пример #10
0
void ProcTracker::TrackInfo2File()
{
	if (m_TrackInfoList.size() < MAX_TRACKINFO && !m_bForceInfo2File)
		return ;
	//如果完成队列中的数据量超过指定的数量,那么就将数据写入到本地文件中
	SECURITY_ATTRIBUTES sa;
	sa.nLength = sizeof(SECURITY_ATTRIBUTES);
	sa.bInheritHandle = FALSE;
	sa.lpSecurityDescriptor = NULL;
	CString strPath;
	//日志默认使用目录为Log
	strPath = GlobalFunc::getCurrentPath() + _T("Log");
	if (!GlobalFunc::DirectoryExist(strPath))
		GlobalFunc::CreateDirectory(strPath);
	//设定日志的名称为时间,最大为一个小时一个文件
	strPath = getLogFilePath();
	HANDLE hFile = CreateFile(strPath, FILE_APPEND_DATA, 0, &sa, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
	if (hFile == INVALID_HANDLE_VALUE)
	{
		m_TrackInfoList.clear();//仍然要清空内存
		CString str = _T("检测到跟踪信息超出额定数量,在将跟踪信息数据写入本地文件时失败!");
		pushTrackInfo(str);
		str = GlobalFunc::formatErrorCode(GetLastError());
		pushTrackInfo(str);
		return ;
	}
	DWORD dwByteWritten = 0;
	CHAR buf[W2FBUFSIZE] = {0};
	CString strAnsi;
	int ansiCount;
	for (std::list<CString>::iterator iter = m_TrackInfoList.begin(); iter != m_TrackInfoList.end(); ++iter)
	{
		ZeroMemory(buf, W2FBUFSIZE);
		strAnsi = *iter;
		ansiCount = GlobalFunc::UnicodeToANSI(strAnsi, buf, W2FBUFSIZE);
		if (iter->GetLength() < BUFSIZE - 2)
		{
			buf[ansiCount] = '\r';
			buf[ansiCount + 1] = '\n';
		}
		WriteFile(hFile, buf, ansiCount + 2, &dwByteWritten, NULL);
	}
	CloseHandle(hFile);
	m_TrackInfoList.clear();//清空内存
}
Пример #11
0
bool CTestMonitor::logWrite(const std::string& sLine)
{
    if (m_isPrintEnabled)
    {
        dbgMsg_s(sLine);
    }
    if (m_isMonitorEnabled)
    {
        FILE* fp = NULL;
        std::string sFilePath = getLogFilePath();
        if ((fp = fopen(sFilePath.c_str(), "a")) == NULL)
        {
            dbgMsg_s("Problem opening log file\n");
            return false;
        }
        unsigned int bytesWritten = fwrite(sLine.c_str(), sizeof (char), sLine.size(), fp);
        fclose(fp);
    }
    return true;
}
Пример #12
0
void LogConfigDialog::selectLogFile()
{
  QString fileExtension;
  QString s = QFileDialog::getSaveFileName(this, tr("Write Log To"), getLogFilePath(), tr("Log(*.log);;Text(*.txt);;All(*.*)"), &fileExtension, QFileDialog::DontUseNativeDialog);
  if (s.length() > 0)
  {
    if (!s.contains('.'))
    {
      if (fileExtension.compare(tr("Log(*.log)"), Qt::CaseInsensitive) == 0)
      {
        s = s + ".log";
      }
      else if (fileExtension.compare(tr("Text(*.txt)"), Qt::CaseInsensitive) == 0)
      {
        s = s + ".txt";
      }
      setLogFilePath(s);
    }
  }
}
Пример #13
0
bool Manager::createLogFile() const
{
    createLogFolder();
#ifdef __linux__
    ofstream file;
    file.open(getLogFilePath().c_str());
    if (!file.is_open())
    {
        return false;
    }
    file.close();
#else
#ifdef __WIN32__

#else
    return false;
#endif
#endif
    return true;

}
Пример #14
0
void LogSettings::getLogFileText(int linearPos, int maxSize, String& strText, int refCircularPos)
{
    if(!isLogToFile())
    {
        return;
    }

    setLogToFile(false);

    int curCircularPos = getLogTextPos();

    common::CRhoFile oFile;
    if(oFile.open(getLogFilePath().c_str(), common::CRhoFile::OpenReadOnly))
    {
        unsigned int fileSize = oFile.size();

        int circularDelta = curCircularPos - refCircularPos;
        if(circularDelta < 0)
        {
            circularDelta += fileSize;
        }

        int pos = linearPos;
        if(pos < circularDelta)
        {
            pos = circularDelta;
        }
        if(refCircularPos > 0)
        {
            pos += refCircularPos;
        }
        if(pos > fileSize)
        {
            pos -= fileSize;
            if(pos >= curCircularPos) {
                maxSize = 0;
            }
        }
        if(pos < curCircularPos)
        {
            int available = curCircularPos - pos;
            if(available < maxSize) maxSize = available;
        }

        oFile.setPosTo(pos);

        char *buffer = new char[maxSize + 1];

        if(fileSize - pos > maxSize) {
            oFile.readData(buffer, 0, maxSize);
        }
        else
        {
            oFile.readData(buffer, 0, fileSize - pos);
            oFile.movePosToStart();
            oFile.readData(buffer, fileSize - pos, maxSize - (fileSize - pos));
        }
        strText.assign(buffer, maxSize);
        delete [] buffer;
    }
    setLogToFile(true);
}
Пример #15
0
void LogSettings::getLogText(String& strText){
    common::CRhoFile oFile;
    if ( oFile.open( getLogFilePath().c_str(), common::CRhoFile::OpenReadOnly) )
        oFile.readString(strText);
}
Пример #16
0
bool LOCACC::validateLocAccJson()
{
    bool returnFlag = true;
    QString logText = "<html><head><title>"+ getInteractivityName() + " Validation-Report"
            "</title></head><body><h1 style='text-align:center;'>Validation Log for " + getInteractivityName() +"</h1>";

    QString messageLogText = "<div><h3 style='text-align: center;'>Repeated Message IDs</h3>"
            "<table border='1' style='text-align: center;margin: auto'>"
            "<thead><tr><th>Screen Id</th><th>Element Id</th><th>Message Id</th><th>Frequency</th></tr></thead>";

    QString elementLogText = "<div><h3 style='text-align: center;'>Repeated Element IDs</h3>"
            "<table border='1' style='text-align: center;margin: auto'>"
            "<thead><tr><th>Screen Id</th><th>Element Id</th><th>Frequency</th></tr></thead>";

    QTreeWidgetItem *screenItem,*elementItem,*messageItem;
    QHash<QString,int> screenMap,elementMap,messageMap ;
    for(int i = 0 ; i < m_qtwiRoot->childCount(); i++)
    {
        screenItem = m_qtwiRoot->child(i);
        screenMap[screenItem->text(0)] = screenMap[screenItem->text(0)] + 1;
        elementMap.clear();
        // Scan each element for duplicate ID entry
        for(int j = 0 ; j < screenItem->childCount() ; j++)
        {
            elementItem = screenItem->child(j);
            elementMap[elementItem->text(0)] = elementMap[elementItem->text(0)] + 1;
            messageMap.clear();
            // Scan each message for duplicate ID entry
            for(int k = 0 ; k < elementItem->childCount() ; k++)
            {
                messageItem = elementItem->child(k);
                messageMap[messageItem->text(0)] = messageMap[messageItem->text(0)] + 1;
            }
            QList<QString> messageIds = messageMap.keys();
            for(int k = 0 ; k < messageIds.length() ; k++)
            {
                int freq = messageMap[messageIds[k]];
                if(freq > 1)
                {
                    messageLogText += "<tr><td>" + screenItem->text(0) + "</td>"
                                       + "<td>" + elementItem->text(0) + "</td>"
                                       + "<td>" + messageIds[k] + "</td>"
                                       + "<td>" + QString::number(freq) + "</td></tr>";
                    returnFlag = false;
                }
            }
        }
        QList<QString> elementIds = elementMap.keys();
        for(int j = 0 ; j < elementIds.length(); j++)
        {
            int freq = elementMap[elementIds[j]];
            if(freq > 1)
            {
                returnFlag = false;
                elementLogText += "<tr><td>" + screenItem->text(0) + "</td>"
                        + "<td>" + elementIds[j] + "</td>"
                        + "<td>" + QString::number(freq) + "</td></tr>";
            }
        }
    }

    messageLogText += "</table></div>";
    elementLogText += "</table></div>";


    QString missingScreenLog = "<h3 style = 'text-align : center'>Missing Screens</h3>"
            "<table border='1' style='text-align: center;margin: auto'>"
            "<thead><tr><th>Index</th><th>Missing Screen Id</th></tr></thead>";
    for(int i = 0 ; i < m_strListMandatoryScreens.length() ; i++)
    {
        if(!screenMap.contains(m_strListMandatoryScreens.at(i)))
        {
            missingScreenLog += "<tr><td>" + QString::number(i+1) + "</td>"
                             + "<td>" + m_strListMandatoryScreens.at(i) + "</td></tr>";
            returnFlag = false;
        }
    }

    missingScreenLog += "</table>";
    logText += messageLogText + "</br>" + elementLogText + "<br>" + missingScreenLog;

    logText += isMessagesArray();

    QString str_htmlFilePath = getLogFilePath() + "-validation.htm";
    QFile htmlLogFile(str_htmlFilePath);
    htmlLogFile.remove();
    htmlLogFile.open(QIODevice::ReadWrite | QIODevice::Text);
    QTextStream out(&htmlLogFile);
    out << logText;
    htmlLogFile.close();
    QDesktopServices::openUrl(QUrl(str_htmlFilePath.replace("\\","/")));
    return returnFlag;
}