From 8335c2a4517b6966a2096b4741e5c7c5f529f3d8 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Mon, 23 Jan 2006 18:59:16 +0000 Subject: [PATCH] Added some user logging to chat.log --- ChangeLog | 3 +++ mbtask/taskchat.c | 25 +++++++++++++++++-------- mbtask/taskchat.h | 1 + 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index e257279a..dca496aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,9 @@ v0.83.8 22-Jan-2006 corrupt bluewave download packets. Bluewave is now big/little endian correct. + mbtask: + Added logging of some user messages to chat.log + v0.83.7 31-Dec-2005 - 22-Jan-2006 diff --git a/mbtask/taskchat.c b/mbtask/taskchat.c index 5e7e493d..ebd825d1 100644 --- a/mbtask/taskchat.c +++ b/mbtask/taskchat.c @@ -85,6 +85,20 @@ int part(pid_t, char*); +void Chatlog(char *level, char *channel, char *msg) +{ + char *logm; + + if (CFG.iAutoLog && strlen(CFG.chat_log)) { + logm = calloc(PATH_MAX, sizeof(char)); + snprintf(logm, PATH_MAX, "%s/log/%s", getenv("MBSE_ROOT"), CFG.chat_log); + ulog(logm, level, channel, (char *)"-1", msg); + free(logm); + } +} + + + void chat_dump(void) { int first; @@ -145,6 +159,7 @@ void system_shout(const char *format, ...) system_msg(tmpu->pid, buf); } + Chatlog((char *)"-", (char *)" ", buf); free(buf); } @@ -353,20 +368,14 @@ void chat_cleanuser(pid_t pid) */ void chat_msg(char *channel, char *nick, char *msg) { - char buf[79], *logm; + char buf[79]; usr_list *tmpu; if (nick == NULL) snprintf(buf, 79, "%s", msg); else snprintf(buf, 79, "<%s> %s", nick, msg); - - if (CFG.iAutoLog && strlen(CFG.chat_log)) { - logm = calloc(PATH_MAX, sizeof(char)); - snprintf(logm, PATH_MAX, "%s/log/%s", getenv("MBSE_ROOT"), CFG.chat_log); - ulog(logm, (char *)"+", channel, (char *)"-1", buf); - free(logm); - } + Chatlog((char *)"+", channel, buf); for (tmpu = users; tmpu; tmpu = tmpu->next) { if (strlen(tmpu->channel) && (strcmp(tmpu->channel, channel) == 0)) { diff --git a/mbtask/taskchat.h b/mbtask/taskchat.h index ea6fede5..6ecee197 100644 --- a/mbtask/taskchat.h +++ b/mbtask/taskchat.h @@ -3,6 +3,7 @@ /* $Id$ */ +void Chatlog(char *, char *, char *); void chat_msg(char *, char *, char *); void system_shout(const char *, ...); void chat_init(void);