Mercurial > pidgin-twitter
changeset 39:2ac81c0afb53
- new debug macro. it includes function name and line number.
- aggregate some debug messages.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Mon, 12 May 2008 22:22:19 +0900 |
parents | 625e385036c3 |
children | e60e6cbdc4c4 |
files | pidgin-twitter.c |
diffstat | 1 files changed, 17 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin-twitter.c Mon May 12 19:46:10 2008 +0900 +++ b/pidgin-twitter.c Mon May 12 22:22:19 2008 +0900 @@ -58,8 +58,8 @@ #define DEFAULT_LIST "(list of users: separated with ' ,:;')" #define OOPS_MESSAGE "<body>Oops! Your update was over 140 characters. We sent the short version to your friends (they can view the entire update on the web).<BR></body>" -#define twitter_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, PLUGIN_NAME, fmt, ## __VA_ARGS__); -#define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PLUGIN_NAME, fmt, ## __VA_ARGS__); +#define twitter_debug(fmt, ...) purple_debug(PURPLE_DEBUG_INFO, PLUGIN_NAME, "%s():%4d: " fmt, __FUNCTION__, (int)__LINE__, ## __VA_ARGS__); +#define twitter_error(fmt, ...) purple_debug(PURPLE_DEBUG_ERROR, PLUGIN_NAME, "%s():%4d: " fmt, __FUCTION__, (int)__LINE__, ## __VA_ARGS__); /* globals */ static GRegex *regp[5]; @@ -79,8 +79,8 @@ /* replace senders with link */ newstr = g_regex_replace(regp[SENDER_WITH_LINK], *str, -1, 0, "@\\1", 0, NULL); - twitter_debug("*str = %s\n", *str); - twitter_debug("rnewstr = %s\n", newstr); + + twitter_debug("*str = %s newstr = %s\n", *str, newstr); g_free(*str); *str = newstr; @@ -125,8 +125,7 @@ if(flag) { /* put ". " to the beginning of buffer */ newstr = g_strdup_printf(". %s", *str); - twitter_debug("*str = %s\n", *str); - twitter_debug("newstr = %s\n", newstr); + twitter_debug("*str = %s newstr = %s\n", *str, newstr); g_free(*str); *str = newstr; } @@ -140,9 +139,8 @@ /* check if the message is from twitter */ proto = purple_account_get_protocol_id(account); - twitter_debug("sending_im_cb\n"); - twitter_debug("proto = %s\n", proto); - twitter_debug("recipient = %s\n", recipient); + twitter_debug("proto = %s recipient = %s\n", + proto, recipient); if(!strcmp(proto, "prpl-jabber") && !strcmp(recipient, "twitter@twitter.com")) { @@ -171,7 +169,8 @@ int which = *(int *)user_data; - snprintf(sub, 128, which ? SENDER_FORMAT : RECIPIENT_FORMAT, match, match); + snprintf(sub, 128, which ? SENDER_FORMAT : RECIPIENT_FORMAT, + match, match); twitter_debug("sub = %s\n", sub); g_string_append(result, sub); g_free(match); @@ -184,8 +183,6 @@ { gchar *newstr; - twitter_debug("*str = %s\n", *str); - newstr = g_regex_replace_eval(regp[which], // compiled regex *str, // subject string -1, // length of the subject string @@ -195,7 +192,7 @@ &which, // user data NULL); // error handler - twitter_debug("newstr = %s\n", newstr); + twitter_debug("*str = %s newstr = %s\n", *str, newstr); g_free(*str); *str = newstr; @@ -249,11 +246,10 @@ /* check if the message is from twitter */ proto = purple_account_get_protocol_id(account); - twitter_debug("writing_im_cb\n"); - twitter_debug("proto = %s\n", proto); - twitter_debug("sender = %s\n", sender); + twitter_debug("proto = %s sender = %s\n", proto, sender); - if(!strcmp(sender, "twitter@twitter.com") && !strcmp(proto, "prpl-jabber")) { + if(!strcmp(sender, "twitter@twitter.com") && + !strcmp(proto, "prpl-jabber")) { /* playsound */ if(purple_prefs_get_bool(OPT_PLAYSOUND_SENDER)) { playsound(buffer, SENDER); @@ -430,9 +426,7 @@ PurpleAccount *account = purple_conversation_get_account(conv); const gchar *proto = purple_account_get_protocol_id(account); - twitter_debug("is_twitter_conv\n"); - twitter_debug("name = %s\n", name); - twitter_debug("proto = %s\n", proto); + twitter_debug("name = %s proto = %s\n", name, proto); if(!strcmp(name, "twitter@twitter.com") && !strcmp(proto, "prpl-jabber")) { return TRUE; @@ -460,14 +454,13 @@ receiving_im_cb(PurpleAccount *account, char **sender, char **buffer, PurpleConversation *conv, PurpleMessageFlags *flags, void *data) { - twitter_debug("receiving_im_cb: buffer = %s\n", *buffer); - twitter_debug("receiving_im_cb: suppress_oops = %d\n", suppress_oops); + twitter_debug("buffer = %s suppress_oops = %d\n", *buffer, suppress_oops); if(!suppress_oops || !purple_prefs_get_bool(OPT_SUPPRESS_OOPS)) return FALSE; if(strstr(*buffer, OOPS_MESSAGE)) { - twitter_debug("receiving_im_cb: clearing sender and buffer\n"); + twitter_debug("clearing sender and buffer\n"); g_free(*sender); *sender = NULL; g_free(*buffer); @@ -518,7 +511,7 @@ static gboolean unload_plugin(PurplePlugin *plugin) { - twitter_debug("pidgin-twitter unload called\n"); + twitter_debug("called\n"); /* disconnect from signal */ purple_signal_disconnect(purple_conversations_get_handle(),