From 39627be1f5efd07febdc6ee545f2e8c5b2603f8d Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 5 Feb 2012 15:22:02 +0000 Subject: [PATCH] Tidied up logging functions --- Makefile | 2 ++ log.c | 5 +++++ log.h | 1 + profanity.c | 10 ++++++++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index be7b41d3..59b5879b 100644 --- a/Makefile +++ b/Makefile @@ -13,3 +13,5 @@ profanity.o: log.h .PHONY: clean clean: rm -f profanity + rm -f profanity.log + rm *.o diff --git a/log.c b/log.c index 4022a20f..4447ae3c 100644 --- a/log.c +++ b/log.c @@ -17,6 +17,11 @@ xmpp_log_t *xmpp_get_file_logger() void xmpp_file_logger(void * const userdata, const xmpp_log_level_t level, const char * const area, const char * const msg) +{ + logmsg(area, msg); +} + +void logmsg(const char * const area, const char * const msg) { fprintf(logp, "%s DEBUG %s\n", area, msg); } diff --git a/log.h b/log.h index 1608167b..c8763cd6 100644 --- a/log.h +++ b/log.h @@ -5,5 +5,6 @@ FILE *logp; xmpp_log_t *xmpp_get_file_logger(); +void logmsg(const char * const area, const char * const msg); #endif diff --git a/profanity.c b/profanity.c index cbc6aefc..98331039 100644 --- a/profanity.c +++ b/profanity.c @@ -9,6 +9,9 @@ // refernce to log extern FILE *logp; +// area for log message in profanity +static const char *prof = "prof"; + // chat windows static WINDOW *incoming_border; static WINDOW *outgoing_border; @@ -49,7 +52,7 @@ int main(void) xmpp_log_t *log; logp = fopen("profanity.log", "a"); - fprintf(logp, "Starting Profanity...\n"); + logmsg(prof, "Starting Profanity..."); init(); print_title(); @@ -64,7 +67,10 @@ int main(void) getstr(passwd); echo(); - fprintf(logp, "Log in, user = %s\n", user); + char loginmsg[100]; + sprintf(loginmsg, "User <%s> logged in", user); + logmsg(prof, loginmsg); + //fprintf(logp, "Log in, user = %s\n", user); xmpp_initialize();