Example #1
0
int main()
{
	log4cplus::Initializer initializer;
	log4cplus::PropertyConfigurator::doConfigure(_T("log4cplus.ini"));	
	/*log4cplus::BasicConfigurator config;
	config.configure();*/

	log4cplus::Logger logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("Main"));
	LOG4CPLUS_INFO_STR(logger, _T("this is the first string."));
	LOG4CPLUS_INFO_FMT(logger, _T("this is the second string %s."), _T("with format"));
	LOG4CPLUS_INFO(logger, _T("output the current thread:") << 2);
	return 0;
}
Example #2
0
void LogHandler::log(const std::string& line, LogLevel level) {
    switch (level) {
    case LL_TRACE:
    {
        LOG4CPLUS_TRACE_STR(log4cplus::Logger::getRoot(), line);
    }
    break;

    case LL_DEBUG:
    {
        LOG4CPLUS_DEBUG_STR(log4cplus::Logger::getRoot(), line);
    }
    break;

    case LL_INFO:
    {
        LOG4CPLUS_INFO_STR(log4cplus::Logger::getRoot(), line);
    }
    break;

    case LL_WARN:
    {
        LOG4CPLUS_WARN_STR(log4cplus::Logger::getRoot(), line);
    }
    break;

    case LL_ERROR:
    {
        LOG4CPLUS_ERROR_STR(log4cplus::Logger::getRoot(), line);
    }
    break;

    case LL_FATAL:
    {
        LOG4CPLUS_FATAL_STR(log4cplus::Logger::getRoot(), line);
    }
    break;
    }
}
Example #3
0
void Database::updateSchema() {
	int dbVersion = getUserSchemaVersion();

	if(dbVersion == CURRENT_DB_SCHEMA_VERSION){
		LOG4CPLUS_INFO_STR(logger,"DB schema is up to date.");
	}else if(dbVersion > CURRENT_DB_SCHEMA_VERSION) {
		LOG4CPLUS_INFO(logger,"DB schema is newer than the current schema, aborting...");
		throw std::runtime_error("DB schema is newer than the current version");
	}else{
		LOG4CPLUS_INFO(logger,"DB schema is out of date, actual: " << dbVersion << " current: " << CURRENT_DB_SCHEMA_VERSION << " updating...");
	switch (dbVersion) {
		case 0:
			exec(const_cast<char *>("ALTER TABLE imagerecord ADD COLUMN `sha256` VARCHAR NOT NULL DEFAULT ''"));
			break;

		default:
			break;
	}

	setUserSchemaVersion(CURRENT_DB_SCHEMA_VERSION);
	}
}