Ejemplo n.º 1
0
Filter::Decision LevelRangeFilter::decide(const LoggingEvent &rEvent) const
{
    if (rEvent.level() < mLevelMin) 
        return Filter::DENY;

    if (rEvent.level() > mLevelMax) 
        return Filter::DENY;
    
    if (mAcceptOnMatch)
	    return Filter::ACCEPT;
    else
        return Filter::NEUTRAL;
}
Ejemplo n.º 2
0
QString SimpleLayout::format(const LoggingEvent &rEvent)
{
    if (mShowLevel)
        return rEvent.level().toString() + QLatin1String(" - ") + rEvent.message() + Layout::endOfLine();
    else
        return rEvent.message() + Layout::endOfLine();
}
Ejemplo n.º 3
0
Filter::Decision LevelMatchFilter::decide(const LoggingEvent &rEvent) const
{
    if (mLevelToMatch == Level::NULL_INT ||
            rEvent.level() != mLevelToMatch)
        return Filter::NEUTRAL;

    if (mAcceptOnMatch)
        return Filter::ACCEPT;
    else
        return Filter::DENY;
}
Ejemplo n.º 4
0
QSqlRecord DatabaseLayout::formatRecord(const LoggingEvent &rEvent)
{
    QSqlField field;
    QSqlRecord record;

    if (!mTimeStamp.isEmpty())
    {
        field.setName(mTimeStamp);
        field.setType(QVariant::DateTime);
        field.setGenerated(true);
        field.setValue(DateTime::fromMSecsSinceEpoch(rEvent.timeStamp()));
        record.append(field);
    }

    if (!mLoggerName.isEmpty())
    {
        field.setName(mLoggerName);
        field.setType(QVariant::String);
        field.setGenerated(true);
        field.setValue(rEvent.loggerName());
        record.append(field);
    }

    if (!mThreadName.isEmpty())
    {
        field.setName(mThreadName);
        field.setType(QVariant::String);
        field.setGenerated(true);
        field.setValue(rEvent.threadName());
        record.append(field);
    }

    if (!mLevel.isEmpty())
    {
        field.setName(mLevel);
        field.setType(QVariant::String);
        field.setGenerated(true);
        field.setValue(rEvent.level().toString());
        record.append(field);
    }

    if (!mMessage.isEmpty())
    {
        field.setName(mMessage);
        field.setType(QVariant::String);
        field.setGenerated(true);
        field.setValue(rEvent.message());
        record.append(field);
    }
    return record;
}
Ejemplo n.º 5
0
	QString BasicPatternConverter::convert(const LoggingEvent &rLoggingEvent) const
	{
		switch (mType)
		{
	        case MESSAGE_CONVERTER:
	    	    return rLoggingEvent.message();
	    	    break;
	        case NDC_CONVERTER:
	        	return rLoggingEvent.ndc();
	        	break;
	        case LEVEL_CONVERTER:
	        	return rLoggingEvent.level().toString();
	        	break;
	        case THREAD_CONVERTER:
	        	return rLoggingEvent.threadName();
	        	break;
	        default:
	        	Q_ASSERT_X(false, "BasicPatternConverter::convert()", "Unkown type constant");
	        	return QString();
		}
	}
Ejemplo n.º 6
0
    void AppenderSkeleton::doAppend(const LoggingEvent &rEvent)
    {
        // The mutex serialises concurrent access from multiple threads.
        // - e.g. two threads using the same logger
        // - e.g. two threads using different logger with the same appender
        //
        // A call from the same thread will pass the mutex (QMutex::Recursive)
        // and get to the recursion guard. The recursion guard blocks recursive
        // invocation and prevents a possible endless loop.
        // - e.g. an appender logs an error with a logger that uses it

        QMutexLocker locker(&mObjectGuard);

        if (mAppendRecursionGuard)
            return;

        RecursionGuardLocker recursion_locker(&mAppendRecursionGuard);

        if (!checkEntryConditions())
            return;
        if (!isAsSevereAsThreshold(rEvent.level()))
            return;

        Filter *p_filter = mpHeadFilter;
        while(p_filter)
        {
            Filter::Decision decision = p_filter->decide(rEvent);
            if (decision == Filter::ACCEPT)
                break;
            else if (decision == Filter::DENY)
                return;
            else
                p_filter = p_filter->next();
        }

        append(rEvent);
    }