Added some user logging to chat.log

This commit is contained in:
Michiel Broek 2006-01-23 18:59:16 +00:00
parent b66973436c
commit 8335c2a451
3 changed files with 21 additions and 8 deletions

View File

@ -7,6 +7,9 @@ v0.83.8 22-Jan-2006
corrupt bluewave download packets. corrupt bluewave download packets.
Bluewave is now big/little endian correct. 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 v0.83.7 31-Dec-2005 - 22-Jan-2006

View File

@ -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) void chat_dump(void)
{ {
int first; int first;
@ -145,6 +159,7 @@ void system_shout(const char *format, ...)
system_msg(tmpu->pid, buf); system_msg(tmpu->pid, buf);
} }
Chatlog((char *)"-", (char *)" ", buf);
free(buf); free(buf);
} }
@ -353,20 +368,14 @@ void chat_cleanuser(pid_t pid)
*/ */
void chat_msg(char *channel, char *nick, char *msg) void chat_msg(char *channel, char *nick, char *msg)
{ {
char buf[79], *logm; char buf[79];
usr_list *tmpu; usr_list *tmpu;
if (nick == NULL) if (nick == NULL)
snprintf(buf, 79, "%s", msg); snprintf(buf, 79, "%s", msg);
else else
snprintf(buf, 79, "<%s> %s", nick, msg); snprintf(buf, 79, "<%s> %s", nick, msg);
Chatlog((char *)"+", channel, buf);
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);
}
for (tmpu = users; tmpu; tmpu = tmpu->next) { for (tmpu = users; tmpu; tmpu = tmpu->next) {
if (strlen(tmpu->channel) && (strcmp(tmpu->channel, channel) == 0)) { if (strlen(tmpu->channel) && (strcmp(tmpu->channel, channel) == 0)) {

View File

@ -3,6 +3,7 @@
/* $Id$ */ /* $Id$ */
void Chatlog(char *, char *, char *);
void chat_msg(char *, char *, char *); void chat_msg(char *, char *, char *);
void system_shout(const char *, ...); void system_shout(const char *, ...);
void chat_init(void); void chat_init(void);