Esempio n. 1
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);
}
Esempio n. 2
0
void LogSettings::loadFromConf(rho::common::RhoSettings& oRhoConf)
{
    if ( oRhoConf.isExist( "MinSeverity" ) )
        setMinSeverity( oRhoConf.getInt("MinSeverity") );
    if ( oRhoConf.isExist( "LogToOutput") )
        setLogToOutput( oRhoConf.getBool("LogToOutput") );
    if ( oRhoConf.isExist( "LogToFile") )
        setLogToFile( oRhoConf.getBool("LogToFile"));
    if ( oRhoConf.isExist( "LogFilePath") )
        setLogFilePath( oRhoConf.getString("LogFilePath").c_str() );
    if ( oRhoConf.isExist( "MaxLogFileSize") )
        setMaxLogFileSize( oRhoConf.getInt("MaxLogFileSize") );
    if ( oRhoConf.isExist( "LogCategories") )
        setEnabledCategories( oRhoConf.getString("LogCategories").c_str() );
    if (oRhoConf.isExist( "ExcludeLogCategories") )
        setDisabledCategories( oRhoConf.getString("ExcludeLogCategories").c_str() );
	if ( oRhoConf.isExist( "LogToSocket") )
		setLogToSocket( oRhoConf.getBool("LogToSocket") );
	if ( oRhoConf.isExist( "rhologurl") )
		setLogURL( oRhoConf.getString("rhologurl").c_str() );
	if ( oRhoConf.isExist( "log_exclude_filter") )
        setExcludeFilter( oRhoConf.getString("log_exclude_filter") );
	if ( oRhoConf.isExist( "LogMemPeriod" ) )
	{
		int milliseconds = oRhoConf.getInt("LogMemPeriod");
		setCollectMemoryInfoInterval(milliseconds);
	}
}
Esempio n. 3
0
CtrlrLog::CtrlrLog(const bool _logToFile)
	:	logToFile(_logToFile),
		fileLogger(nullptr)
{
	CtrlrLog::ctrlrLog = this;

	setLogToFile (logToFile);
}
Esempio n. 4
0
void LogSettings::loadFromConf(rho::common::RhoSettings& oRhoConf){
    if ( oRhoConf.isExist( "MinSeverity" ) )
        setMinSeverity( oRhoConf.getInt("MinSeverity") );
    if ( oRhoConf.isExist( "LogToOutput") )
        setLogToOutput( oRhoConf.getBool("LogToOutput") );
    if ( oRhoConf.isExist( "LogToFile") )
        setLogToFile( oRhoConf.getBool("LogToFile"));
    if ( oRhoConf.isExist( "LogFilePath") )
        setLogFilePath( oRhoConf.getString("LogFilePath").c_str() );
    if ( oRhoConf.isExist( "MaxLogFileSize") )
        setMaxLogFileSize( oRhoConf.getInt("MaxLogFileSize") );
    if ( oRhoConf.isExist( "LogCategories") )
        setEnabledCategories( oRhoConf.getString("LogCategories").c_str() );
    if (oRhoConf.isExist( "ExcludeLogCategories") )
        setDisabledCategories( oRhoConf.getString("ExcludeLogCategories").c_str() );
}
Esempio n. 5
0
int main(){
    int pid;
	SOCKET socketfd;
    socklen_t length;
    static struct sockaddr_in clientAddress;

	setLogLevel(LOG_WARN);
	setAppName("WEB");
	setLogToFile(TRUE);

    signal(SIGCHLD, SIG_IGN); /* ignore child death */
	signal(SIGINT,  sigHandler);	// Trap Ctrl-C in case we are running interactively
	signal(SIGTERM, sigHandler);	// Trap termination requests from the system

    readDbConfig();

    listener = setupListener();

    while (1){
        length = sizeof(clientAddress);

        socketfd = accept(listener, (struct sockaddr *) &clientAddress, &length);
   		
        if (socketfd < 0){
            logMsg(LOG_ERR, "accept() returned %d, %s", socketfd, strerror(errno));
        } else {
            pid = fork();
            //TODO drop privs after fork
            if (pid == 0){
             // We are in the child process
                close(listener);
                web(socketfd);

            } else if (pid > 0){
             // We are still in the parent process
                close(socketfd);

            } else {
                logMsg(LOG_ERR, "fork() returned %d, %s", pid, strerror(errno));
                exit(1);
            }
        }
    }

    return 0;
}
Esempio n. 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);
}