X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=blobdiff_plain;f=src%2FEventLogger.c;h=e131478b54bc8d8379e2dcb54ae947c224a455ec;hp=d0b61bde6f42999711b72103204dd6a3ac713ab1;hb=HEAD;hpb=0f1dc61921eef1db8e404a5a82372e2d1cd55daa diff --git a/src/EventLogger.c b/src/EventLogger.c index d0b61bd..e131478 100644 --- a/src/EventLogger.c +++ b/src/EventLogger.c @@ -1,3 +1,19 @@ +/* EventLogger.c - NeonServ v5.6 + * Copyright (C) 2011-2012 Philipp Kreil (pk910) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include "EventLogger.h" #include "modcmd.h" @@ -5,21 +21,22 @@ #include "UserNode.h" #include "ChanNode.h" #include "DBHelper.h" +#include "log.h" static struct Event *first_event = NULL, *last_event = NULL; -struct Event *createEvent(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, char *command, char **args, int argc, int flags) { +struct Event *createEvent(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct cmd_binding *command, char **args, int argc, int flags) { struct Event *event = malloc(sizeof(*event)); if (!event) { - perror("malloc() failed"); + printf_log("main", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__); return NULL; } event->client = client; event->user = user; event->chan = chan; event->event_time = time(0); - event->command = strdup(command); + event->command = command; char arguments[MAXLEN]; int argpos = 0; int i; @@ -41,7 +58,7 @@ struct Event *createEvent(struct ClientSocket *client, struct UserNode *user, st void logEvent(struct Event *event) { char fullcmd[MAXLEN]; - sprintf(fullcmd, "%s %s", event->command, event->arguments); + sprintf(fullcmd, "%s %s", event->command->func->name, event->arguments); if((event->flags & CMDFLAG_LOG) && event->chan) { char *auth = ((event->user->flags & USERFLAG_ISAUTHED) ? event->user->auth : "*"); loadChannelSettings(event->chan); @@ -59,9 +76,12 @@ void logEvent(struct Event *event) { userid = 0; else userid = atoi(row[0]); - loadChannelSettings(event->chan); - if((event->chan->flags & CHANFLAG_CHAN_REGISTERED)) - printf_mysql_query("INSERT INTO `godlog` (`godlog_cid`, `godlog_uid`, `godlog_time`, `godlog_cmd`) VALUES ('%d', '%d', UNIX_TIMESTAMP(), '%s')", event->chan->channel_id, userid, escape_string(fullcmd)); + if(event->chan) { + loadChannelSettings(event->chan); + if((event->chan->flags & CHANFLAG_CHAN_REGISTERED)) + printf_mysql_query("INSERT INTO `godlog` (`godlog_cid`, `godlog_uid`, `godlog_time`, `godlog_cmd`) VALUES ('%d', '%d', UNIX_TIMESTAMP(), '%s')", event->chan->channel_id, userid, escape_string(fullcmd)); + } + printf_log("main", LOG_OVERRIDE, "[%s:%s (%s)] %s", (event->chan ? event->chan->name : "*"), event->user->nick, auth, fullcmd); } } @@ -74,7 +94,6 @@ static void destroyEvent(struct Event *event) { if(last->next == NULL) break; last_event = last; } - free(event->command); free(event->arguments); free(event); }