示例#1
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;
}
示例#2
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();
		}
	}