Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Re #274: Swap print for debug to honour log level
Browse files Browse the repository at this point in the history
Also combined logging to a single line now we don't pretty-print
and removed double-logging for DMs (once in the block of all retrieved
DMs and once when they get faux-streamed).

But since that may hide non-"message_create" messages, we now log
the JSON earlier, before we drop unsupported messages.
  • Loading branch information
IBBoard committed Jan 9, 2021
1 parent 9160017 commit 62a7efd
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions src/CbUserStream.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,19 @@ stream_tweet (CbUserStream *self,
JsonNode *node) {
guint i;

if (message_type == CB_STREAM_MESSAGE_UNSUPPORTED) {
g_debug ("Skipped unsupported message on stream @%s\n", self->account_name);
return;
}

#if DEBUG
g_print ("Message with type %d on stream @%s\n", message_type, self->account_name);

JsonGenerator *gen = json_generator_new ();
json_generator_set_root (gen, node);
json_generator_set_pretty (gen, FALSE);
gchar *json_dump = json_generator_to_data (gen, NULL);
g_print ("%s\n", json_dump);
g_debug ("Message with type %d on stream @%s: %s", message_type, self->account_name, json_dump);
#endif

if (message_type == CB_STREAM_MESSAGE_UNSUPPORTED) {
g_debug ("Skipped unsupported message on stream @%s\n", self->account_name);
return;
}

for (i = 0; i < self->receivers->len; i++) {
cb_message_receiver_stream_message_received (g_ptr_array_index (self->receivers, i),
message_type,
Expand Down Expand Up @@ -582,16 +580,6 @@ load_dm_tweets_done (GObject *source_object,
return;
}

#if DEBUG
g_print ("DMs on @%s\n", self->account_name);

JsonGenerator *gen = json_generator_new ();
json_generator_set_root (gen, root_node);
json_generator_set_pretty (gen, FALSE);
gchar *json_dump = json_generator_to_data (gen, NULL);
g_print ("%s\n", json_dump);
#endif

root_obj = json_node_get_object (root_node);
root_arr = json_object_get_array_member(root_obj, "events");
len = json_array_get_length (root_arr);
Expand Down Expand Up @@ -634,7 +622,7 @@ load_dm_tweets_done (GObject *source_object,
self->new_last_dm_id = id;
}
}
g_debug("New DM with type: %s", type);

stream_tweet (self, message_type, node);
}

Expand Down

0 comments on commit 62a7efd

Please sign in to comment.