From b16c75d98c57b8f1efa26ab6eae35431c04c4c1e Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 21 Sep 2008 19:58:55 +0200 Subject: Printf-artige Funktion logf zum Logger hinzugef?gt --- src/Client/CommandParser.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/Client') diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp index ccf5a74..87202b4 100644 --- a/src/Client/CommandParser.cpp +++ b/src/Client/CommandParser.cpp @@ -59,7 +59,7 @@ void CommandParser::printUsage(const std::string& command) { const CommandParser::Command *cmd = findCommand(command); if(cmd) - Common::Logger::log(std::string("Usage: ") + cmd->cmdline + "\n"); + Common::Logger::logf("Usage: %s\n", cmd->cmdline); } void CommandParser::printHostStatus(const Net::Packets::HostStatusPacket &packet) { @@ -135,10 +135,10 @@ void CommandParser::helpCommand(const std::vector &args) { std::cout << command->longdesc << std::endl << std::endl; } else - Common::Logger::log(Common::Logger::WARNING, args[0] + ": Command '" + args[1] + "' doesn't exist.\n"); + Common::Logger::logf(Common::Logger::WARNING,"%s: Command '%s' doesn't exist.\n", args[0].c_str(), args[1].c_str()); } else { - Common::Logger::log(Common::Logger::ERROR, args[0] + ": Too many arguments."); + Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str()); printUsage("help"); } } @@ -154,7 +154,7 @@ void CommandParser::listHostsCommand(const std::vector &args) { ); } else if(args.size() > 2) { - Common::Logger::log(Common::Logger::ERROR, args[0] + ": Too many arguments."); + Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str()); printUsage("list_hosts"); return; } @@ -168,7 +168,7 @@ void CommandParser::listHostsCommand(const std::vector &args) { ); } else { - Common::Logger::log(Common::Logger::ERROR, args[0] + ": Don't unterstand argument '" + args[1] + "'."); + Common::Logger::logf(Common::Logger::ERROR, "%s: Don't unterstand argument '%s'.", args[0].c_str(), args[1].c_str()); printUsage("list_hosts"); return; } @@ -182,7 +182,7 @@ void CommandParser::statusCommand(const std::vector &args) { else if(args.size() == 2) Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr(new Requests::DaemonStatusRequest(args[1], sigc::mem_fun(this, &CommandParser::daemonStatusRequestFinished)))); else { - Common::Logger::log(Common::Logger::ERROR, args[0] + ": Too many arguments."); + Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str()); printUsage("status"); return; } @@ -203,7 +203,7 @@ void CommandParser::coreStatusRequestFinished(const Common::Request &request) disconnect = true; } catch(Common::Exception &exception) { - Common::Logger::log(Common::Logger::ERROR, std::string("An error occurred during your request: ") + exception.strerror() + ".\n"); + Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.\n", exception.strerror().c_str()); } requestFinished(); @@ -344,7 +344,7 @@ bool CommandParser::parse(const std::string &cmd) { if(command) (this->*command->funcPtr)(splitCmd); else - Common::Logger::log(Common::Logger::ERROR, "Unknown command '" + splitCmd[0] + "'.\n"); + Common::Logger::logf(Common::Logger::ERROR, "Unknown command '%s'.\n", splitCmd[0].c_str()); return true; } -- cgit v1.2.3