Errors to stderr, debug output to stdout

This commit is contained in:
tastytea 2018-05-12 14:24:53 +02:00
parent ca261ca031
commit 73640c3b66
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
3 changed files with 10 additions and 9 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7) cmake_minimum_required (VERSION 3.7)
project (expandurl-mastodon project (expandurl-mastodon
VERSION 0.2.1 VERSION 0.2.2
LANGUAGES CXX LANGUAGES CXX
) )

View File

@ -78,15 +78,15 @@ int main(int argc, char *argv[])
std::this_thread::sleep_for(std::chrono::seconds(2)); std::this_thread::sleep_for(std::chrono::seconds(2));
if (!listener.stillrunning()) if (!listener.stillrunning())
{ {
cerr << "DEBUG: Reestablishing connection...\n"; cout << "DEBUG: Reestablishing connection...\n";
listener.start(); listener.start();
} }
for (Easy::Notification &notif : listener.get_new_messages()) for (Easy::Notification &notif : listener.get_new_messages())
{ {
cerr << "DEBUG: new messages\n"; cout << "DEBUG: new messages\n";
const std::uint_fast64_t id = listener.get_parent_id(notif); const std::uint_fast64_t id = listener.get_parent_id(notif);
cerr << "DEBUG: in_reply_to_id: " << id << '\n'; cout << "DEBUG: in_reply_to_id: " << id << '\n';
Easy::Status status; Easy::Status status;
if (id > 0) if (id > 0)
@ -103,7 +103,7 @@ int main(int argc, char *argv[])
{ {
if (!listener.send_reply(notif.status(), message)) if (!listener.send_reply(notif.status(), message))
{ {
cerr << "FIXME!\n"; cerr << "ERROR: could not send reply to " << id << '\n';
} }
} }
else else

View File

@ -21,6 +21,7 @@
#include "expandurl-mastodon.hpp" #include "expandurl-mastodon.hpp"
using std::cerr; using std::cerr;
using std::cout;
using std::string; using std::string;
Listener::Listener() Listener::Listener()
@ -61,7 +62,7 @@ const void Listener::start()
masto.set_useragent(static_cast<const string>("expandurl-mastodon/") + masto.set_useragent(static_cast<const string>("expandurl-mastodon/") +
global::version); global::version);
masto.get_stream(Mastodon::API::v1::streaming_user, _stream, _ptr); masto.get_stream(Mastodon::API::v1::streaming_user, _stream, _ptr);
cerr << "DEBUG: Connection lost.\n"; cout << "DEBUG: Connection lost.\n";
_running = false; _running = false;
}); });
} }
@ -105,7 +106,7 @@ Mastodon::Easy::Status Listener::get_status(const std::uint_fast64_t &id)
} }
else else
{ {
cerr << "ERROR: " << ret << '\n'; cerr << "ERROR: " << ret << " (in " << __FUNCTION__ << ")\n";
return Easy::Status(); return Easy::Status();
} }
} }
@ -152,12 +153,12 @@ const bool Listener::send_reply(const Easy::Status &to_status,
if (ret == 0) if (ret == 0)
{ {
cerr << "DEBUG: Sent reply: " << message << '\n'; cout << "DEBUG: Sent reply: " << message << '\n';
return true; return true;
} }
else else
{ {
cerr << "ERROR: could not send reply to " << id << '\n'; cerr << "ERROR: " << ret << " (in " << __FUNCTION__ << ")\n";
return false; return false;
} }
} }