From f66a36de911ca01a0b109a9a145a5b46bebdd0e1 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 1 Jul 2009 16:36:27 +0200 Subject: UserCache: Ordentliche Debug-Ausgaben --- src/Common/Application.cpp | 2 +- src/Common/UserCache.cpp | 22 +++++++++++++--------- src/Common/UserCache.h | 5 ++++- src/Common/UserManager.cpp | 2 +- src/Common/UserManager.h | 6 ++++-- 5 files changed, 23 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/Common/Application.cpp b/src/Common/Application.cpp index 6eca8d3..2b3ff9e 100644 --- a/src/Common/Application.cpp +++ b/src/Common/Application.cpp @@ -27,7 +27,7 @@ namespace Mad { namespace Common { Application::Application(bool server) : moduleManager(new ModuleManager(this)), requestManager(new RequestManager(this, server)), -systemManager(new SystemManager), userManager(new UserManager) {} +systemManager(new SystemManager), userManager(new UserManager(this)) {} Application::~Application() { delete userManager; diff --git a/src/Common/UserCache.cpp b/src/Common/UserCache.cpp index 79f27c7..887e375 100644 --- a/src/Common/UserCache.cpp +++ b/src/Common/UserCache.cpp @@ -18,8 +18,7 @@ */ #include "UserCache.h" - -#include +#include "Application.h" namespace Mad { namespace Common { @@ -28,11 +27,13 @@ boost::shared_ptr > UserCache::getUserLi boost::lock_guard lock(mutex); if(users) { - std::cerr << "Cached" << std::endl; + application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Using cached user list"); return users; } - else if(userException) + else if(userException) { + application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Error cached"); throw userException; + } try { users = backend->getUserList(); @@ -105,11 +106,13 @@ boost::shared_ptr > UserCache::getGroup boost::lock_guard lock(mutex); if(groups) { - std::cerr << "Cached" << std::endl; + application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Using cached group list"); return groups; } - else if(groupException) + else if(groupException) { + application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Error cached"); throw groupException; + } try { groups = backend->getGroupList(); @@ -181,12 +184,13 @@ boost::shared_ptr > UserCache: boost::lock_guard lock(mutex); if(userGroups) { - std::cerr << "Cached" << std::endl; + application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Using cached user-group table"); return userGroups; } - else if(userGroupException) + else if(userGroupException) { + application->log(Core::LoggerBase::USER, Core::LoggerBase::DEBUG, "Error cached"); throw userGroupException; - + } try { userGroups = backend->getFullUserGroupList(); diff --git a/src/Common/UserCache.h b/src/Common/UserCache.h index cec5ea5..548be2e 100644 --- a/src/Common/UserCache.h +++ b/src/Common/UserCache.h @@ -29,12 +29,15 @@ namespace Mad { namespace Common { +class Application; class UserManager; class UserCache : public UserBackend, private boost::noncopyable { private: friend class UserManager; + Application *application; + boost::shared_ptr backend; boost::shared_mutex mutex; @@ -72,7 +75,7 @@ class UserCache : public UserBackend, private boost::noncopyable { backend->addUser(userInfo); } - UserCache(boost::shared_ptr backend0) : backend(backend0) {} + UserCache(Application *application0, boost::shared_ptr backend0) : application(application0), backend(backend0) {} }; } diff --git a/src/Common/UserManager.cpp b/src/Common/UserManager.cpp index c56195d..1b20395 100644 --- a/src/Common/UserManager.cpp +++ b/src/Common/UserManager.cpp @@ -36,7 +36,7 @@ bool UserManager::Compare::operator() (boost::shared_ptr b1, boost: void UserManager::registerBackendCached(boost::shared_ptr backend) { { boost::lock_guard lock(mutex); - backends.insert(std::make_pair(backend, boost::shared_ptr(new UserCache(backend)))); + backends.insert(std::make_pair(backend, boost::shared_ptr(new UserCache(application, backend)))); } } diff --git a/src/Common/UserManager.h b/src/Common/UserManager.h index 1ba051f..c545f01 100644 --- a/src/Common/UserManager.h +++ b/src/Common/UserManager.h @@ -38,7 +38,7 @@ class Application; class UserBackend; class UserCache; -class UserManager : boost::noncopyable { +class UserManager : private boost::noncopyable { private: friend class Application; @@ -48,11 +48,13 @@ class UserManager : boost::noncopyable { typedef std::map, boost::shared_ptr, Compare> BackendMap; + Application *application; + BackendMap backends; boost::shared_mutex mutex; - UserManager() {} + UserManager(Application *application0) : application(application0) {} public: void registerBackend(boost::shared_ptr backend) { -- cgit v1.2.3