Updated XMPP server to new logging standard
authorArt Cancro <ajc@citadel.org>
Thu, 30 Mar 2017 20:42:33 +0000 (16:42 -0400)
committerArt Cancro <ajc@citadel.org>
Thu, 30 Mar 2017 20:42:33 +0000 (16:42 -0400)
citadel/modules/xmpp/serv_xmpp.c
citadel/modules/xmpp/serv_xmpp.h
citadel/modules/xmpp/xmpp_presence.c
citadel/modules/xmpp/xmpp_query_namespace.c
citadel/modules/xmpp/xmpp_queue.c
citadel/modules/xmpp/xmpp_sasl_service.c

index 36b1d33ce998be92d06b708a6272cbaac6f13954..2ee2493cc1fe8b6e48fbbbe53e4ef64826be5228 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * XMPP (Jabber) service for the Citadel system
- * Copyright (c) 2007-2015 by Art Cancro and citadel.org
+ * Copyright (c) 2007-2017 by Art Cancro and citadel.org
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -76,7 +76,7 @@ static void xmpp_entity_declaration(void *userData, const XML_Char *entityName,
                                const XML_Char *systemId, const XML_Char *publicId,
                                const XML_Char *notationName
 ) {
-       XMPPM_syslog(LOG_WARNING, "Illegal entity declaration encountered; stopping parser.");
+       syslog(LOG_WARNING, "xmpp: illegal entity declaration encountered; stopping parser.");
        XML_StopParser(XMPP->xp, XML_FALSE);
 }
 #endif
@@ -240,9 +240,9 @@ void xmpp_xml_start(void *data, const char *supplied_el, const char **attr) {
        }
 
        /*
-       XMPP_syslog(LOG_DEBUG, "XMPP ELEMENT START: <%s>\n", el);
+       syslog(LOG_DEBUG, "xmpp: ELEMENT START: <%s>", el);
        for (i=0; attr[i] != NULL; i+=2) {
-               XMPP_syslog(LOG_DEBUG, "                    Attribute '%s' = '%s'\n", attr[i], attr[i+1]);
+               syslog(LOG_DEBUG, "xmpp: Attribute '%s' = '%s'", attr[i], attr[i+1]);
        }
        uncomment for more verbosity */
 
@@ -312,9 +312,9 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
        }
 
        /*
-       XMPP_syslog(LOG_DEBUG, "XMPP ELEMENT END  : <%s>\n", el);
+       syslog(LOG_DEBUG, "xmpp: ELEMENT END  : <%s>", el);
        if (XMPP->chardata_len > 0) {
-               XMPP_syslog(LOG_DEBUG, "          chardata: %s\n", XMPP->chardata);
+               syslog(LOG_DEBUG, "xmpp: chardata: %s", XMPP->chardata);
        }
        uncomment for more verbosity */
 
@@ -375,10 +375,7 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
                         * Unknown query ... return the XML equivalent of a blank stare
                         */
                        else {
-                               XMPP_syslog(LOG_DEBUG,
-                                           "Unknown query <%s> - returning <service-unavailable/>\n",
-                                           el
-                               );
+                               syslog(LOG_DEBUG, "xmpp: Unknown query <%s> - returning <service-unavailable/>", el);
                                cprintf("<iq type=\"error\" id=\"%s\">", xmlesc(xmlbuf, XMPP->iq_id, sizeof xmlbuf));
                                cprintf("<error code=\"503\" type=\"cancel\">"
                                        "<service-unavailable xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"
@@ -510,7 +507,7 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
        }
 
        else if (!strcasecmp(el, "stream")) {
-               XMPPM_syslog(LOG_DEBUG, "XMPP client shut down their stream\n");
+               syslog(LOG_DEBUG, "xmpp: client shut down their stream");
                xmpp_massacre_roster();
                cprintf("</stream>\n");
                CC->kill_me = KILLME_CLIENT_LOGGED_OUT;
@@ -525,7 +522,7 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
        }
 
        else {
-               XMPP_syslog(LOG_DEBUG, "Ignoring unknown tag <%s>\n", el);
+               syslog(LOG_DEBUG, "xmpp: ignoring unknown tag <%s>", el);
        }
 
        XMPP->chardata_len = 0;
@@ -590,7 +587,7 @@ void xmpp_greeting(void) {
 
        XMPP->xp = XML_ParserCreateNS("UTF-8", ':');
        if (XMPP->xp == NULL) {
-               XMPPM_syslog(LOG_ALERT, "Cannot create XML parser!\n");
+               syslog(LOG_ERR, "xmpp: cannot create XML parser");
                CC->kill_me = KILLME_XML_PARSER;
                return;
        }
@@ -627,7 +624,7 @@ void xmpp_command_loop(void) {
                XML_Parse(XMPP->xp, ChrPtr(stream_input), rc, 0);
        }
        else {
-               XMPPM_syslog(LOG_ERR, "client disconnected: ending session.\n");
+               syslog(LOG_ERR, "xmpp: client disconnected: ending session.");
                CC->kill_me = KILLME_CLIENT_DISCONNECTED;
        }
        FreeStrBuf(&stream_input);
index 27f3410544f857ee5defc7d907e19a9b4702da76..222c8f79ff738cea78182c4559e79221831b8064 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2009 by the citadel.org team
+ * Copyright (c) 2007-2017 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
@@ -77,15 +77,3 @@ void xmpp_massacre_roster(void);
 void xmpp_delete_old_buddies_who_no_longer_exist_from_the_client_roster(void);
 int xmpp_is_visible(struct CitContext *from, struct CitContext *to_whom);
 char *xmlesc(char *buf, char *str, int bufsiz);
-
-extern int XMPPSrvDebugEnable;
-
-#define DBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (XMPPSrvDebugEnable != 0))
-
-#define XMPP_syslog(LEVEL, FORMAT, ...)                                \
-       DBGLOG(LEVEL) syslog(LEVEL,                             \
-                            "XMPP: " FORMAT, __VA_ARGS__)
-
-#define XMPPM_syslog(LEVEL, FORMAT)            \
-       DBGLOG(LEVEL) syslog(LEVEL,             \
-                            "XMPP: " FORMAT);
index 4c4fa9335c5ed578b8eceaa8f72fe300d3048099..2d498078422a5dc11b4ed7cb10a21e7d6b249676 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Handle XMPP presence exchanges
  *
- * Copyright (c) 2007-2015 by Art Cancro and citadel.org
+ * Copyright (c) 2007-2017 by Art Cancro and citadel.org
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -67,7 +67,7 @@ void xmpp_indicate_presence(char *presence_jid)
 {
        char xmlbuf[256];
 
-       XMPP_syslog(LOG_DEBUG, "XMPP: indicating presence of <%s> to <%s>", presence_jid, XMPP->client_jid);
+       syslog(LOG_DEBUG, "xmpp: indicating presence of <%s> to <%s>", presence_jid, XMPP->client_jid);
        cprintf("<presence from=\"%s\" ", xmlesc(xmlbuf, presence_jid, sizeof xmlbuf));
        cprintf("to=\"%s\"></presence>", xmlesc(xmlbuf, XMPP->client_jid, sizeof xmlbuf));
 }
@@ -195,11 +195,11 @@ void xmpp_presence_notify(char *presence_jid, int event_type) {
                }
        }
 
-       XMPP_syslog(LOG_DEBUG, "%d sessions for <%s> are now visible to session %d\n", visible_sessions, presence_jid, CC->cs_pid);
+       syslog(LOG_DEBUG, "xmpp: %d sessions for <%s> are now visible to session %d", visible_sessions, presence_jid, CC->cs_pid);
 
        if ( (event_type == XMPP_EVT_LOGIN) && (visible_sessions == 1) ) {
 
-               XMPP_syslog(LOG_DEBUG, "Telling session %d that <%s> logged in\n", CC->cs_pid, presence_jid);
+               syslog(LOG_DEBUG, "xmpp: telling session %d that <%s> logged in", CC->cs_pid, presence_jid);
 
                /* Do an unsolicited roster update that adds a new contact. */
                assert(which_cptr_is_relevant >= 0);
@@ -213,8 +213,7 @@ void xmpp_presence_notify(char *presence_jid, int event_type) {
        }
 
        if (visible_sessions == 0) {
-               XMPP_syslog(LOG_DEBUG, "Telling session %d that <%s> logged out\n",
-                           CC->cs_pid, presence_jid);
+               syslog(LOG_DEBUG, "xmpp: telling session %d that <%s> logged out", CC->cs_pid, presence_jid);
                xmpp_destroy_buddy(presence_jid, 0);    /* non aggressive presence update */
        }
 
@@ -270,7 +269,7 @@ void xmpp_fetch_mortuary_backend(long msgnum, void *userdata) {
 HashList *xmpp_fetch_mortuary(void) {
        HashList *mortuary = NewHash(1, NULL);
        if (!mortuary) {
-               XMPPM_syslog(LOG_ALERT, "NewHash() failed!\n");
+               syslog(LOG_ALERT, "xmpp: NewHash() failed!");
                return(NULL);
        }
 
index a517f2a5070f23c1e61d5bb61c13167a36fd835e..8016a635730405d78c56fd8f8aeb078193bdf7db 100644 (file)
@@ -78,13 +78,13 @@ void xmpp_iq_roster_query(void)
        struct CitContext *cptr;
        int nContexts, i;
 
-       XMPPM_syslog(LOG_DEBUG, "Roster push!");
+       syslog(LOG_DEBUG, "xmpp: roster push!");
        cprintf("<query xmlns=\"jabber:iq:roster\">");
        cptr = CtdlGetContextArray(&nContexts);
        if (cptr) {
                for (i=0; i<nContexts; i++) {
                        if (xmpp_is_visible(&cptr[i], CC)) {
-                               XMPP_syslog(LOG_DEBUG, "Rosterizing %s\n", cptr[i].user.fullname);
+                               syslog(LOG_DEBUG, "xmpp: rosterizing %s", cptr[i].user.fullname);
                                xmpp_roster_item(&cptr[i]);
                        }
                }
@@ -97,7 +97,6 @@ void xmpp_iq_roster_query(void)
 
 /*
  * Client is doing a namespace query.  These are all handled differently.
- * A "rumplestiltskin lookup" is the most efficient way to handle this.  Please do not refactor this code.
  */
 void xmpp_query_namespace(char *iq_id, char *iq_from, char *iq_to, char *query_xmlns)
 {
@@ -119,7 +118,7 @@ void xmpp_query_namespace(char *iq_id, char *iq_from, char *iq_to, char *query_x
                supported_namespace = 1;
        }
 
-       XMPP_syslog(LOG_DEBUG, "xmpp_query_namespace(id=%s, from=%s, to=%s, xmlns=%s)\n", iq_id, iq_from, iq_to, query_xmlns);
+       syslog(LOG_DEBUG, "xmpp: xmpp_query_namespace(id=%s, from=%s, to=%s, xmlns=%s)", iq_id, iq_from, iq_to, query_xmlns);
 
        /*
         * Beginning of query result.
@@ -195,7 +194,7 @@ void xmpp_query_namespace(char *iq_id, char *iq_from, char *iq_to, char *query_x
         */
 
        else {
-               XMPP_syslog(LOG_DEBUG, "Unknown query namespace '%s' - returning <service-unavailable/>\n", query_xmlns);
+               syslog(LOG_DEBUG, "xmpp: unknown query namespace '%s' - returning <service-unavailable/>", query_xmlns);
                cprintf("<error code=\"503\" type=\"cancel\">"
                        "<service-unavailable xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"
                        "</error>"
index 4b031bca536806cf877ba2921e1a964186b9b6b4..8cdf1a4d8a28fd5a523beec22dd5acf5cffbf4ba 100644 (file)
@@ -1,22 +1,15 @@
 /*
  * XMPP event queue
  *
- * Copyright (c) 2007-2009 by Art Cancro
+ * Copyright (c) 2007-2017 by Art Cancro
  *
- *  This program is open source software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3.
- *  
- *  
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  
- *  
- *  
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
  *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  */
 
 #include "sysdep.h"
@@ -66,7 +59,7 @@ void xmpp_queue_event(int event_type, char *email_addr) {
        int purged_something = 0;
        struct CitContext *cptr;
 
-       MARK_syslog(LOG_DEBUG, "xmpp_queue_event(%d, %s)\n", event_type, email_addr);
+       syslog(LOG_DEBUG, "xmpp: xmpp_queue_event(%d, %s)", event_type, email_addr);
 
        /* Purge events more than a minute old */
        begin_critical_section(S_XMPP_QUEUE);
index 393174dce18b2cf78901e61aa1955743d84f08fc..ce2c8890bce65bbd332f435853deda65c314cd56 100644 (file)
@@ -5,20 +5,13 @@
  *
  * Copyright (c) 2007-2009 by Art Cancro
  *
- *  This program is open source software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3.
- *  
- *  
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  
- *  
- *  
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
  *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  */
 
 #include "sysdep.h"