Moved logging, added log level paramater to standalone runner

This commit is contained in:
James Booth
2015-06-08 22:18:48 +01:00
parent ad6728e74b
commit 954d3a2128
6 changed files with 33 additions and 16 deletions

View File

@@ -131,10 +131,10 @@ static char*
_levelstr(stbbr_log_t loglevel)
{
switch (loglevel) {
case STBBR_LOGERROR: return "ERROR";
case STBBR_LOGWARN: return "WARN";
case STBBR_LOGINFO: return "INFO";
case STBBR_LOGDEBUG: return "DEBUG";
case STBBR_LOGERROR: return "ERR";
case STBBR_LOGWARN: return "WRN";
case STBBR_LOGINFO: return "INF";
case STBBR_LOGDEBUG: return "DBG";
default: return "";
}
}

View File

@@ -27,6 +27,7 @@
#include "server/stanza.h"
#include "server/stanzas.h"
#include "server/log.h"
static char *required_passwd = NULL;
static GHashTable *idstubs = NULL;
@@ -60,6 +61,8 @@ prime_free_all(void)
void
prime_required_passwd(char *password)
{
log_println(STBBR_LOGDEBUG, "Received auth password: %s", password);
free(required_passwd);
required_passwd = strdup(password);
}
@@ -74,6 +77,8 @@ void
prime_for_id(const char *id, char *stream)
{
if (idstubs) {
log_println(STBBR_LOGDEBUG, "Received stub for id: %s, stanza: %s", id, stream);
g_hash_table_insert(idstubs, strdup(id), strdup(stream));
}
}
@@ -88,6 +93,8 @@ void
prime_for_query(const char *query, char *stream)
{
if (querystubs) {
log_println(STBBR_LOGDEBUG, "Received stub for query: %s, stanza: %s", query, stream);
XMPPStanza *stanza = stanza_parse(stream);
g_hash_table_insert(querystubs, strdup(query), stanza);
}

View File

@@ -241,7 +241,7 @@ query_callback(const char *query, const char *id)
void
server_wait_for(char *id)
{
log_println(STBBR_LOGINFO, "WAIT for stanza with id: %s", id);
log_println(STBBR_LOGINFO, "Received wait for stanza with id: %s", id);
while (TRUE) {
int res = stanzas_contains_id(id);
if (res) {
@@ -376,6 +376,8 @@ server_run(stbbr_log_t loglevel, int port, int httpport)
void
server_send(char *stream)
{
log_println(STBBR_LOGDEBUG, "Received send: %s", stream);
pthread_mutex_lock(&send_queue_lock);
send_queue = g_list_append(send_queue, strdup(stream));
pthread_mutex_unlock(&send_queue_lock);

View File

@@ -34,6 +34,8 @@ static int timeoutsecs = 0;
void
verify_set_timeout(int seconds)
{
log_println(STBBR_LOGDEBUG, "Setting timeout: %d seconds", seconds);
if (seconds <= 0) {
timeoutsecs = 0;
} else {