summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-12-03 19:10:44 +0100
committerFlorent Le Coz <louiz@louiz.org>2013-12-03 19:15:37 +0100
commita4c845ab6c54172ea305f33734c83238c75d421a (patch)
tree3ed5393e993f0e9b72fabd9413453fadbfe9a9a9 /src/irc
parent2662ed89e2cd41477582140e482f1ddbbfdb235e (diff)
downloadbiboumi-a4c845ab6c54172ea305f33734c83238c75d421a.tar.gz
biboumi-a4c845ab6c54172ea305f33734c83238c75d421a.tar.bz2
biboumi-a4c845ab6c54172ea305f33734c83238c75d421a.tar.xz
biboumi-a4c845ab6c54172ea305f33734c83238c75d421a.zip
Use the logger everywhere
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/irc_client.cpp17
-rw-r--r--src/irc/irc_user.cpp1
2 files changed, 7 insertions, 11 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index 4e5efe1..1a9e61b 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -4,7 +4,7 @@
#include <irc/irc_user.hpp>
#include <utils/make_unique.hpp>
-// #include <logger/logger.hpp>
+#include <logger/logger.hpp>
#include <utils/tolower.hpp>
#include <utils/split.hpp>
@@ -18,12 +18,10 @@ IrcClient::IrcClient(const std::string& hostname, const std::string& username, B
bridge(bridge),
welcomed(false)
{
- std::cout << "IrcClient()" << std::endl;
}
IrcClient::~IrcClient()
{
- std::cout << "~IrcClient()" << std::endl;
}
void IrcClient::start()
@@ -39,7 +37,7 @@ void IrcClient::on_connected()
void IrcClient::on_connection_close()
{
- std::cout << "Connection closed by remote server." << std::endl;
+ log_warning("Connection closed by remote server.");
}
IrcChannel* IrcClient::get_channel(const std::string& name)
@@ -74,18 +72,19 @@ void IrcClient::parse_in_buffer()
if (pos == std::string::npos)
break ;
IrcMessage message(this->in_buf.substr(0, pos));
+ log_debug("IRC RECEIVING: " << message);
this->in_buf = this->in_buf.substr(pos + 2, std::string::npos);
- std::cout << message << std::endl;
auto cb = irc_callbacks.find(message.command);
if (cb != irc_callbacks.end())
(this->*(cb->second))(message);
else
- std::cout << "No handler for command " << message.command << std::endl;
+ log_info("No handler for command " << message.command);
}
}
void IrcClient::send_message(IrcMessage&& message)
{
+ log_debug("IRC SENDING: " << message);
std::string res;
if (!message.prefix.empty())
res += ":" + std::move(message.prefix) + " ";
@@ -101,8 +100,6 @@ void IrcClient::send_message(IrcMessage&& message)
res += " " + arg;
}
res += "\r\n";
- std::cout << "=== IRC SENDING ===" << std::endl;
- std::cout << res << std::endl;
this->send_data(std::move(res));
}
@@ -134,7 +131,7 @@ bool IrcClient::send_channel_message(const std::string& chan_name, const std::st
IrcChannel* channel = this->get_channel(chan_name);
if (channel->joined == false)
{
- std::cout << "Cannot send message to channel " << chan_name << ", it is not joined" << std::endl;
+ log_warning("Cannot send message to channel " << chan_name << ", it is not joined");
return false;
}
this->send_message(IrcMessage("PRIVMSG", {chan_name, body}));
@@ -185,7 +182,7 @@ void IrcClient::set_and_forward_user_list(const IrcMessage& message)
IrcUser* user = channel->add_user(nick);
if (user->nick != channel->get_self()->nick)
{
- std::cout << "Adding user [" << nick << "] to chan " << chan_name << std::endl;
+ log_debug("Adding user [" << nick << "] to chan " << chan_name);
this->bridge->send_user_join(this->hostname, chan_name, user->nick);
}
}
diff --git a/src/irc/irc_user.cpp b/src/irc/irc_user.cpp
index afe8623..f9866ef 100644
--- a/src/irc/irc_user.cpp
+++ b/src/irc/irc_user.cpp
@@ -24,5 +24,4 @@ IrcUser::IrcUser(const std::string& name)
this->nick = name.substr(0, sep);
this->host = name.substr(sep+1);
}
- std::cout << "Created user: [" << this->nick << "!" << this->host << std::endl;
}