Changeset - fcd00635e9d6
[Not reviewed]
0 2 0
HanzZ - 13 years ago 2012-12-07 17:00:03
hanzz.k@gmail.com
filter out sqlite3 error about already created buddies table. do not log XML by default
2 files changed with 4 insertions and 1 deletions:
0 comments (0 inline, 0 general)
spectrum/src/logging.cfg
Show inline comments
 
log4j.rootLogger=debug, R
 

	
 
log4j.appender.R=org.apache.log4j.RollingFileAppender
 
log4j.appender.R.File=/var/log/spectrum2/${jid}/spectrum2.log
 

	
 
log4j.appender.R.MaxFileSize=10000KB
 
# Keep one backup file
 
log4j.appender.R.MaxBackupIndex=1
 

	
 
log4j.appender.R.layout=org.apache.log4j.PatternLayout
 
log4j.appender.R.layout.ConversionPattern=%d %-5p %c: %m%n
 

	
 
# Disable XML category
 
log4j.category.Component.XML = OFF
src/sqlite3backend.cpp
Show inline comments
 
@@ -187,49 +187,49 @@ bool SQLite3Backend::createDatabase() {
 
		exec("CREATE TABLE " + m_prefix + "users_settings ("
 
					"  user_id int(10) NOT NULL,"
 
					"  var varchar(50) NOT NULL,"
 
					"  type int(4) NOT NULL,"
 
					"  value varchar(4095) NOT NULL,"
 
					"  PRIMARY KEY (user_id, var)"
 
					");");
 
					
 
		exec("CREATE INDEX IF NOT EXISTS user_id03 ON " + m_prefix + "users_settings (user_id);");
 

	
 
		exec("CREATE TABLE IF NOT EXISTS " + m_prefix + "db_version ("
 
			"  ver INTEGER NOT NULL DEFAULT '3'"
 
			");");
 
		exec("REPLACE INTO " + m_prefix + "db_version (ver) values(3)");
 
	}
 
	return true;
 
}
 

	
 
bool SQLite3Backend::exec(const std::string &query) {
 
	char *errMsg = 0;
 
	int rc = sqlite3_exec(m_db, query.c_str(), NULL, 0, &errMsg);
 
	if (rc != SQLITE_OK) {
 
		// This error is OK, because we try to create buddies table every time
 
		// to detect if DB is created properly.
 
		if (errMsg != "table buddies already exists") {
 
		if (errMsg && std::string(errMsg).find("table buddies already exists") == std::string::npos) {
 
			LOG4CXX_ERROR(logger, errMsg << " during statement " << query);
 
		}
 
		sqlite3_free(errMsg);
 
		return false;
 
	}
 
	return true;
 
}
 

	
 
void SQLite3Backend::setUser(const UserInfo &user) {
 
	sqlite3_reset(m_setUser);
 
	sqlite3_bind_text(m_setUser, 1, user.jid.c_str(), -1, SQLITE_STATIC);
 
	sqlite3_bind_text(m_setUser, 2, user.uin.c_str(), -1, SQLITE_STATIC);
 
	sqlite3_bind_text(m_setUser, 3, user.password.c_str(), -1, SQLITE_STATIC);
 
	sqlite3_bind_text(m_setUser, 4, user.language.c_str(), -1, SQLITE_STATIC);
 
	sqlite3_bind_text(m_setUser, 5, user.encoding.c_str(), -1, SQLITE_STATIC);
 
	sqlite3_bind_int (m_setUser, 6, user.vip);
 

	
 
	if(sqlite3_step(m_setUser) != SQLITE_DONE) {
 
		LOG4CXX_ERROR(logger, "setUser query"<< (sqlite3_errmsg(m_db) == NULL ? "" : sqlite3_errmsg(m_db)));
 
	}
 
}
 

	
 
bool SQLite3Backend::getUser(const std::string &barejid, UserInfo &user) {
 
// 	SELECT id, jid, uin, password, encoding, language, vip FROM " + m_prefix + "users WHERE jid=?
0 comments (0 inline, 0 general)