From 1a43fad56dc945c72a4ab711d2c9ff6d1a5a1502 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 30 Sep 2009 22:28:33 +0200 Subject: Added Format class for improved logging experience :) --- .../ChallengeResponseAuthenticator.cpp | 2 +- .../Authenticators/PasswordAuthenticator.cpp | 2 +- src/Client/InformationManager.cpp | 2 +- src/Common/ModuleManager.cpp | 6 +- src/Common/UserManager.cpp | 16 ++--- src/Core/Application.cpp | 65 +------------------ src/Core/Application.h | 29 ++++----- src/Core/CMakeLists.txt | 1 + src/Core/Exception.h | 6 ++ src/Core/Format.h | 72 ++++++++++++++++++++++ src/Core/LogManager.cpp | 2 +- src/Net/Connection.cpp | 8 +-- src/Server/ConnectionManager.cpp | 2 +- .../ConnectionRequestHandlerGroup.cpp | 2 +- src/madc.cpp | 2 +- src/madd.cpp | 2 +- src/modules/AuthProviderFile/AuthProviderFile.cpp | 6 +- src/modules/FileLogger/Module.cpp | 2 +- .../StorageBackendFile/StorageBackendFile.cpp | 2 +- .../UserConfigBackendHome.cpp | 4 +- .../UserConfigBackendKrb5.cpp | 6 +- .../UserConfigBackendKrb5/UserConfigBackendKrb5.h | 2 +- 22 files changed, 130 insertions(+), 111 deletions(-) create mode 100644 src/Core/Format.h diff --git a/src/Client/Authenticators/ChallengeResponseAuthenticator.cpp b/src/Client/Authenticators/ChallengeResponseAuthenticator.cpp index 92ced08..4c5fbf3 100644 --- a/src/Client/Authenticators/ChallengeResponseAuthenticator.cpp +++ b/src/Client/Authenticators/ChallengeResponseAuthenticator.cpp @@ -115,7 +115,7 @@ void ChallengeResponseAuthenticator::authenticate(Common::Application *applicati throw Core::Exception(Core::Exception::NOT_AVAILABLE); } - application->logf(Core::Logger::LOG_VERBOSE, "Authenticating with method 'Challenge-Response' using hash '%s'...", hash.toLocale().c_str()); + application->log(Core::Logger::LOG_VERBOSE, Core::Format("Authenticating with method 'Challenge-Response' using hash '%1%'...") % hash); boost::shared_ptr request(new ChallengeResponseAuthRequest(application, username, password, hash)); diff --git a/src/Client/Authenticators/PasswordAuthenticator.cpp b/src/Client/Authenticators/PasswordAuthenticator.cpp index ac01d44..a4691a5 100644 --- a/src/Client/Authenticators/PasswordAuthenticator.cpp +++ b/src/Client/Authenticators/PasswordAuthenticator.cpp @@ -98,7 +98,7 @@ void PasswordAuthenticator::authenticate(Common::Application *application, Commo throw Core::Exception(Core::Exception::NOT_AVAILABLE); } - application->logf(Core::Logger::LOG_VERBOSE, "Authenticating with method 'Password' using hash '%s'...", hash.toLocale().c_str()); + application->log(Core::Logger::LOG_VERBOSE, Core::Format("Authenticating with method 'Password' using hash '%1%'...") % hash); boost::shared_ptr request(new PasswordAuthRequest(application, username, password, hash)); diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp index 10827d9..5ef78d6 100644 --- a/src/Client/InformationManager.cpp +++ b/src/Client/InformationManager.cpp @@ -73,7 +73,7 @@ void InformationManager::daemonListRequestFinished(boost::shared_ptr lock(mutex); if(!packet || error) { - application->logf(Core::Logger::LOG_CRITICAL, "Host list request failed: %s", error.what()); + application->log(Core::Logger::LOG_CRITICAL, Core::Format("Host list request failed: %1%") % error); } else { const Common::XmlData::List *list = packet->getList("hosts"); diff --git a/src/Common/ModuleManager.cpp b/src/Common/ModuleManager.cpp index c119eab..0347971 100644 --- a/src/Common/ModuleManager.cpp +++ b/src/Common/ModuleManager.cpp @@ -62,7 +62,7 @@ void ModuleManager::configure() { std::vector entries = application->getConfigManager()->getEntries("LoadModule"); for(std::vector::iterator entry = entries.begin(); entry != entries.end(); ++entry) { if(!loadModule((*entry)->getValue().toLocale())) - application->logf(Core::Logger::LOG_ERROR, "Can't load module '%s'.", (*entry)->getValue().toLocale().c_str()); + application->log(Core::Logger::LOG_ERROR, Core::Format("Can't load module '%1%'.") % (*entry)->getValue()); } } @@ -88,9 +88,9 @@ bool ModuleManager::loadModule(const std::string &name) { if(!handle) { #ifdef WIN32 - application->logf(Core::Logger::LOG_VERBOSE, "loadModule: Can't open module: Error %u", GetLastError()); + application->log(Core::Logger::LOG_VERBOSE, Core::Format("loadModule: Can't open module: Error %1%") % GetLastError()); #else - application->logf(Core::Logger::LOG_VERBOSE, "loadModule: Can't open module: %s", dlerror()); + application->log(Core::Logger::LOG_VERBOSE, Core::Format("loadModule: Can't open module: %1%") % dlerror()); #endif return false; } diff --git a/src/Common/UserManager.cpp b/src/Common/UserManager.cpp index e71c38e..917c61a 100644 --- a/src/Common/UserManager.cpp +++ b/src/Common/UserManager.cpp @@ -39,29 +39,29 @@ UserManager::~UserManager() { void UserManager::configure() { minUid = std::strtoul(application->getConfigManager()->get("UserManager.MinUid", "1000").toString().c_str(), 0, 10); if(minUid == 0) { - application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MinUid '%s'", - application->getConfigManager()->get("UserManager.MinUid").toLocale().c_str()); + application->log(Core::Logger::LOG_WARNING, Core::Format("UserBackendHome: Invalid configuration: MinUid '%1%'") + % application->getConfigManager()->get("UserManager.MinUid")); minUid = 1000; } maxUid = std::strtoul(application->getConfigManager()->get("UserManager.MaxUid", "29999").toString().c_str(), 0, 10); if(maxUid == 0) { - application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MaxUid '%s'", - application->getConfigManager()->get("UserManager.MaxUid").toLocale().c_str()); + application->log(Core::Logger::LOG_WARNING, Core::Format("UserBackendHome: Invalid configuration: MaxUid '%1%'") + % application->getConfigManager()->get("UserManager.MaxUid")); maxUid = 29999; } minGid = std::strtoul(application->getConfigManager()->get("UserManager.MinGid", "1000").toString().c_str(), 0, 10); if(minGid == 0) { - application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MinGid '%s'", - application->getConfigManager()->get("UserManager.MinGid").toLocale().c_str()); + application->log(Core::Logger::LOG_WARNING, Core::Format("UserBackendHome: Invalid configuration: MinGid '%1%'") + % application->getConfigManager()->get("UserManager.MinGid")); minGid = 1000; } maxGid = std::strtoul(application->getConfigManager()->get("UserManager.MaxGid", "29999").toString().c_str(), 0, 10); if(maxGid == 0) { - application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MaxGid '%s'", - application->getConfigManager()->get("UserManager.MaxGid").toLocale().c_str()); + application->log(Core::Logger::LOG_WARNING, Core::Format("UserBackendHome: Invalid configuration: MaxGid '%1%'") + % application->getConfigManager()->get("UserManager.MaxGid")); maxGid = 29999; } } diff --git a/src/Core/Application.cpp b/src/Core/Application.cpp index 86b5b7b..83ef3a7 100644 --- a/src/Core/Application.cpp +++ b/src/Core/Application.cpp @@ -23,11 +23,7 @@ #include "ThreadManager.h" #include -#include - -#ifndef va_copy -# define va_copy(d, s) (d) = (s) -#endif +#include namespace Mad { namespace Core { @@ -46,66 +42,9 @@ Application::~Application() { delete configManager; } - -void Application::logfv(Logger::MessageCategory category, Logger::MessageLevel level, const Core::String &format, va_list ap) { - int size = 100; - char *buf = (char*)std::malloc(size); - - // If buffer is too small, try again with bigger buffer - while(true) { - va_list ap2; - - va_copy(ap2, ap); - int n = vsnprintf(buf, size, format.toLocale().c_str(), ap2); - va_end(ap2); - - if(n > -1 && n < size) { - logManager->log(category, level, boost::posix_time::microsec_clock::universal_time(), Core::String::fromLocale(buf)); - std::free(buf); - return; - } - - if(n > -1) - size = n+1; - else - size *= 2; - - buf = (char*)std::realloc(buf, size); - } - -} - -void Application::log(Logger::MessageCategory category, Logger::MessageLevel level, const Core::String &message) { +void Application::doLog(Logger::MessageCategory category, Logger::MessageLevel level, const Core::String &message) { logManager->log(category, level, boost::posix_time::microsec_clock::universal_time(), message); } -void Application::logf(Logger::MessageCategory category, Logger::MessageLevel level, const Core::String &format, ...) { - va_list ap; - va_start(ap, format); - logfv(category, level, format, ap); - va_end(ap); -} - -void Application::logf(Logger::MessageCategory category, const Core::String &format, ...) { - va_list ap; - va_start(ap, format); - logfv(category, Logger::LOG_DEFAULT, format, ap); - va_end(ap); -} - -void Application::logf(Logger::MessageLevel level, const Core::String &format, ...) { - va_list ap; - va_start(ap, format); - logfv(Logger::LOG_GENERAL, level, format, ap); - va_end(ap); -} - -void Application::logf(const Core::String &format, ...) { - va_list ap; - va_start(ap, format); - logfv(Logger::LOG_GENERAL, Logger::LOG_DEFAULT, format, ap); - va_end(ap); -} - } } diff --git a/src/Core/Application.h b/src/Core/Application.h index ffab639..7f7ec76 100644 --- a/src/Core/Application.h +++ b/src/Core/Application.h @@ -22,11 +22,10 @@ #include "export.h" +#include "Format.h" #include "Logger.h" -#include -#include - +#include #include #include @@ -45,7 +44,7 @@ class MAD_CORE_EXPORT Application : private boost::noncopyable { LogManager *logManager; ThreadManager *threadManager; - void logfv(Logger::MessageCategory category, Logger::MessageLevel level, const Core::String &format, va_list ap); + void doLog(Logger::MessageCategory category, Logger::MessageLevel level, const Core::String &message); protected: Application(); @@ -69,25 +68,27 @@ class MAD_CORE_EXPORT Application : private boost::noncopyable { } - void log(Logger::MessageCategory category, Logger::MessageLevel level, const Core::String &message); + template + void log(Logger::MessageCategory category, Logger::MessageLevel level, const T &message) { + std::ostringstream stream; + stream << message; + doLog(category, level, String::fromLocale(stream.str())); + } - void log(Logger::MessageCategory category, const Core::String &message) { + template + void log(Logger::MessageCategory category, const T &message) { log(category, Logger::LOG_DEFAULT, message); } - void log(Logger::MessageLevel level, const Core::String &message) { + template + void log(Logger::MessageLevel level, const T &message) { log(Logger::LOG_GENERAL, level, message); } - void log(const Core::String &message) { + template + void log(const T &message) { log(Logger::LOG_GENERAL, Logger::LOG_DEFAULT, message); } - - - void logf(Logger::MessageCategory category, Logger::MessageLevel level, const Core::String &format, ...); - void logf(Logger::MessageCategory category, const Core::String &format, ...); - void logf(Logger::MessageLevel level, const Core::String &format, ...); - void logf(const Core::String &format, ...); }; } diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index 60a5a25..9b458c5 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -16,6 +16,7 @@ mad_library(Core ConfigManager.cpp ConfigManager.h Configurable.h Exception.cpp Exception.h + Format.h Logger.h LogManager.cpp LogManager.h Signals.h diff --git a/src/Core/Exception.h b/src/Core/Exception.h index 48688a4..1d8eb40 100644 --- a/src/Core/Exception.h +++ b/src/Core/Exception.h @@ -82,6 +82,12 @@ class MAD_CORE_EXPORT Exception : public std::exception { } }; +template +std::basic_ostream& operator<<(std::basic_ostream &stream, const Exception &exception) { + stream << exception.toString(); + return stream; +} + } } diff --git a/src/Core/Format.h b/src/Core/Format.h new file mode 100644 index 0000000..bd57af5 --- /dev/null +++ b/src/Core/Format.h @@ -0,0 +1,72 @@ +/* + * Format.h + * + * Copyright (C) 2009 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program. If not, see . + */ + +#ifndef MAD_CORE_FORMAT_H_ +#define MAD_CORE_FORMAT_H_ + +#include "String.h" + +#include + +namespace Mad { +namespace Core { + +class Format { + private: + boost::format format; + + public: + Format(const String &formatString) : format(formatString.toLocale()) {} + + void clear() { + format.clear(); + } + + Format& parse(const String &formatString) { + format.parse(formatString.toLocale()); + return *this; + } + + String str() const { + return String::fromLocale(format.str()); + } + + template + Format& operator%(T &x) { + format % x; + return *this; + } + + template + Format& operator%(const T &x) { + format % x; + return *this; + } +}; + +template +std::basic_ostream& operator<<(std::basic_ostream &stream, const Format &format) { + stream << format.str(); + return stream; +} + +} +} + +#endif /* MAD_CORE_FORMAT_H_ */ diff --git a/src/Core/LogManager.cpp b/src/Core/LogManager.cpp index 955ac76..7aac571 100644 --- a/src/Core/LogManager.cpp +++ b/src/Core/LogManager.cpp @@ -105,7 +105,7 @@ void LogManager::configure() { consoleLogger->setLevel(parseLevel(level)); } catch(Core::Exception e) { - application->logf(Logger::LOG_WARNING, "Unknown log level '%s'.", level.toLocale().c_str()); + application->log(Logger::LOG_WARNING, Format("Unknown log level '%1%'.") % level); } } } diff --git a/src/Net/Connection.cpp b/src/Net/Connection.cpp index f66a3df..ace771f 100644 --- a/src/Net/Connection.cpp +++ b/src/Net/Connection.cpp @@ -35,7 +35,7 @@ Connection::~Connection() { void Connection::handleHandshake(const boost::system::error_code& error) { if(error) { - application->logf(Core::Logger::LOG_NETWORK, "Error: %s", error.message().c_str()); + application->log(Core::Logger::LOG_NETWORK, Core::Format("Error: %1%") % error.message()); // TODO Error handling doDisconnect(); @@ -64,7 +64,7 @@ void Connection::handleShutdown(const boost::system::error_code& error) { boost::lock_guard lock(connectionLock); if(error) { - application->logf(Core::Logger::LOG_NETWORK, Core::Logger::LOG_VERBOSE, "Shutdown error: %s", error.message().c_str()); + application->log(Core::Logger::LOG_NETWORK, Core::Logger::LOG_VERBOSE, Core::Format("Shutdown error: %1%") % error.message()); } _setState(DISCONNECTED); @@ -121,7 +121,7 @@ void Connection::handleRead(const boost::system::error_code& error, std::size_t if(error == boost::system::errc::operation_canceled) return; - application->logf(Core::Logger::LOG_NETWORK, "Read error: %s", error.message().c_str()); + application->log(Core::Logger::LOG_NETWORK, Core::Format("Read error: %1%") % error.message()); // TODO Error doDisconnect(); @@ -182,7 +182,7 @@ void Connection::rawReceive(std::size_t length, const boost::function1logf(Core::Logger::LOG_NETWORK, Core::Logger::LOG_VERBOSE, "Write error: %s", error.message().c_str()); + application->log(Core::Logger::LOG_NETWORK, Core::Logger::LOG_VERBOSE, Core::Format("Write error: %1%") % error.message()); { boost::unique_lock lock(connectionLock); diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp index a3d3d26..70adaa0 100644 --- a/src/Server/ConnectionManager.cpp +++ b/src/Server/ConnectionManager.cpp @@ -130,7 +130,7 @@ void ConnectionManager::configure() { listeners.push_back(listener); } catch(Core::Exception &e) { - application->logf(Core::Logger::LOG_WARNING, "ConnectionManager: Invalid listen address '%s'", (*listenEntry)->getValue().toLocale().c_str()); + application->log(Core::Logger::LOG_WARNING, Core::Format("ConnectionManager: Invalid listen address '%1%'") % (*listenEntry)->getValue()); } } } diff --git a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp index 8045db1..4d97aa8 100644 --- a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp @@ -109,7 +109,7 @@ void ConnectionRequestHandlerGroup::handleLogRequest(boost::shared_ptrgetConnectionManager()->getDaemonName(connection)); } catch(Core::Exception &e) { - application->logf(Core::Logger::LOG_ERROR, "Can't determine daemon name: %s", e.what()); + application->log(Core::Logger::LOG_ERROR, Core::Format("Can't determine daemon name: %1%") % e); } ret->setType("OK"); diff --git a/src/madc.cpp b/src/madc.cpp index 40138cd..477dc04 100644 --- a/src/madc.cpp +++ b/src/madc.cpp @@ -155,7 +155,7 @@ int main(int argc, char *argv[]) { application.getUserManager()->unregisterBackend(networkUserBackend); } catch(Core::Exception &e) { - application.logf(Core::Logger::LOG_CRITICAL, "Error: %s", e.what()); + application.log(Core::Logger::LOG_CRITICAL, Core::Format("Error: %s") % e); } application.getRequestManager()->unregisterConnection(connection); diff --git a/src/madd.cpp b/src/madd.cpp index 710e69f..ad81b22 100644 --- a/src/madd.cpp +++ b/src/madd.cpp @@ -71,7 +71,7 @@ int main() { application.getRequestManager()->unregisterConnection(connection); } catch(Core::Exception &e) { - application.logf(Core::Logger::LOG_CRITICAL, "Connection error: %s", e.what()); + application.log(Core::Logger::LOG_CRITICAL, Core::Format("Error: %1%") % e); } delete connection; diff --git a/src/modules/AuthProviderFile/AuthProviderFile.cpp b/src/modules/AuthProviderFile/AuthProviderFile.cpp index 4522092..7ce1fae 100644 --- a/src/modules/AuthProviderFile/AuthProviderFile.cpp +++ b/src/modules/AuthProviderFile/AuthProviderFile.cpp @@ -35,7 +35,7 @@ namespace AuthProviderFile { void AuthProviderFile::readFile(const std::string &name) { std::ifstream stream(name.c_str()); if(!stream.good()) { - application->logf(Core::Logger::LOG_WARNING, "AuthProviderFile: Can't read file '%s'.", name.c_str()); + application->log(Core::Logger::LOG_WARNING, Core::Format("AuthProviderFile: Can't read file '%1%'.") % name); return; } @@ -50,7 +50,7 @@ void AuthProviderFile::readFile(const std::string &name) { boost::smatch match; if(!boost::regex_match(line, match, regex)) { - application->logf(Core::Logger::LOG_WARNING, "AuthProviderFile: Malformed line in file '%s'.", name.c_str()); + application->log(Core::Logger::LOG_WARNING, Core::Format("AuthProviderFile: Malformed line in file '%s'.") % name); continue; } @@ -72,7 +72,7 @@ void AuthProviderFile::readFile(const std::string &name) { unsigned char byte; if(std::sscanf(buffer, "%hhx", &byte) != 1) { - application->logf(Core::Logger::LOG_WARNING, "AuthProviderFile: Malformed hash in file '%s'.", name.c_str()); + application->log(Core::Logger::LOG_WARNING, Core::Format("AuthProviderFile: Malformed hash in file '%s'.") % name); data.clear(); break; } diff --git a/src/modules/FileLogger/Module.cpp b/src/modules/FileLogger/Module.cpp index 25a54b4..cfaf47f 100644 --- a/src/modules/FileLogger/Module.cpp +++ b/src/modules/FileLogger/Module.cpp @@ -54,7 +54,7 @@ void Module::configure() { logger->setLevel(Core::LogManager::parseLevel(level)); } catch(Core::Exception e) { - application->logf(Core::Logger::LOG_WARNING, "Unknown log level '%s'.", level.toLocale().c_str()); + application->log(Core::Logger::LOG_WARNING, Core::Format("Unknown log level '%1%'.") % level); } } } diff --git a/src/modules/StorageBackendFile/StorageBackendFile.cpp b/src/modules/StorageBackendFile/StorageBackendFile.cpp index e801a64..c7017c0 100644 --- a/src/modules/StorageBackendFile/StorageBackendFile.cpp +++ b/src/modules/StorageBackendFile/StorageBackendFile.cpp @@ -38,7 +38,7 @@ void StorageBackendFile::configure() { } if(!boost::filesystem::is_directory(storageRoot)) { - application->logf("StorageBackendFile: Can't create directory: '%s'.", storageRoot.string().c_str()); + application->log(Core::Format("StorageBackendFile: Can't create directory: '%1%'.") % storageRoot.string()); return; } diff --git a/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp b/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp index a19769c..fc90705 100644 --- a/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp +++ b/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp @@ -37,8 +37,8 @@ void UserConfigBackendHome::configure() { dirMode = std::strtoul(application->getConfigManager()->get("UserManager.UserDirMode", "775").toString().c_str(), 0, 8); if(dirMode > 07777) { - application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: UserDirMode '%s'", - application->getConfigManager()->get("UserManager.UserDirMode").toLocale().c_str()); + application->log(Core::Logger::LOG_WARNING, Core::Format("UserBackendHome: Invalid configuration: UserDirMode '%1%'") + % application->getConfigManager()->get("UserManager.UserDirMode")); dirMode = 0775; } } diff --git a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp index 61ad996..72c8160 100644 --- a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp +++ b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp @@ -68,7 +68,7 @@ void UserConfigBackendKrb5::_connect() { const_cast(KADM5_ADMIN_SERVICE), ¶ms, KADM5_STRUCT_VERSION, KADM5_API_VERSION_2, 0, &handle); if(err) { - application->logf(Core::Logger::LOG_USER, Core::Logger::LOG_ERROR, "kadm5_init_with_password: %s", krb5_get_error_message(context, err)); + application->log(Core::Logger::LOG_USER, Core::Logger::LOG_ERROR, Core::Format("kadm5_init_with_password: %1%") % krb5_get_error_message(context, err)); return; } } @@ -84,7 +84,7 @@ void UserConfigBackendKrb5::_connect() { const_cast(KADM5_ADMIN_SERVICE), ¶ms, KADM5_STRUCT_VERSION, KADM5_API_VERSION_2, 0, &handle); if(err) { - application->logf(Core::Logger::LOG_USER, Core::Logger::LOG_ERROR, "kadm5_init_with_skey: %s", krb5_get_error_message(context, err)); + application->log(Core::Logger::LOG_USER, Core::Logger::LOG_ERROR, Core::Format("kadm5_init_with_skey: %1%") % krb5_get_error_message(context, err)); return; } } @@ -226,7 +226,7 @@ void UserConfigBackendKrb5::deleteUser(const Common::UserInfo &userInfo) throw(C krb5_free_principal(context, princ); if(err) - application->logf(Core::Logger::LOG_USER, Core::Logger::LOG_WARNING, "kadm5_delete_principal: %s", krb5_get_error_message(context, err)); + application->log(Core::Logger::LOG_USER, Core::Logger::LOG_WARNING, Core::Format("kadm5_delete_principal: %1%") % krb5_get_error_message(context, err)); } void UserConfigBackendKrb5::setPassword(const Common::UserInfo &userInfo, const Core::String &password) throw(Core::Exception) { diff --git a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h index 64f8501..c02f868 100644 --- a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h +++ b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h @@ -64,7 +64,7 @@ class UserConfigBackendKrb5 : public Common::UserConfigBackend, private Core::Co UserConfigBackendKrb5(Common::Application *application0) : application(application0), handle(0) { krb5_error_code err = krb5_init_context(&context); if(err) { - application->logf("Unable to initialize kerberos context: %s", std::strerror(err)); + application->log(Core::Format("Unable to initialize kerberos context: %1%") % std::strerror(err)); context = 0; return; } -- cgit v1.2.3