Пример #1
0
unsigned int LogSettings::getLogFileSize()
{
    if(!isLogToFile())
    {
        return 0;
    }
    return common::CRhoFile::getFileSize(getLogFilePath().c_str());
}
Пример #2
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 );
}
Пример #3
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);
}
Пример #4
0
void LogSettings::sinkLogMessage( String& strMsg ){
    common::CMutexLock oLock(m_FlushLock);

    if ( isLogToFile() )
        m_pFileSink->writeLogMessage(strMsg);

    if (m_pLogViewSink)
        m_pLogViewSink->writeLogMessage(strMsg);

    //Should be at the end
    if ( isLogToOutput() )
        m_pOutputSink->writeLogMessage(strMsg);
}
Пример #5
0
void LogSettings::internalSinkLogMessage( String& strMsg ){
    common::CMutexLock oLock(m_FlushLock);

	if ( isLogToFile() )
        m_pFileSink->writeLogMessage(strMsg);

    if (m_pLogViewSink)
        m_pLogViewSink->writeLogMessage(strMsg);

    //Should be at the end
    if ( isLogToOutput() )
        m_pOutputSink->writeLogMessage(strMsg);

	if (m_bLogToSocket && m_pSocketSink)
        m_pSocketSink->writeLogMessage(strMsg);
    
    if (m_pAuxSinks.size() > 0)
    {
        for (Hashtable<ILogSink*, bool>::const_iterator it = m_pAuxSinks.begin(); it != m_pAuxSinks.end(); it++) {
            (*it).first->writeLogMessage(strMsg);
        }
    }
}
Пример #6
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);
}