summaryrefslogtreecommitdiff
path: root/logging.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-09-16 20:21:06 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-09-16 20:21:06 +0100
commit424ba496e6affc6d9421b1ce7147b34bf5c7913b (patch)
tree95fa5b961c13a1eb671bda109f8db0ecdd633180 /logging.c
parent7a3a8aa2a521f752a042ede37b81125689aa0067 (diff)
Log user/channel mode setting in the replay and normal logs.
Diffstat (limited to 'logging.c')
-rw-r--r--logging.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/logging.c b/logging.c
index b000c28..2079822 100644
--- a/logging.c
+++ b/logging.c
@@ -52,6 +52,9 @@
// :oldnick!bar@baz NICK :newnick
// Same manual 'channelname' prepending as LOG_QUIT above.
//
+// If LOG_MODE then it expects a string in the format:
+// :nick!bar@baz MODE #channel foo bar [foo bar...]
+//
// With the ":foo!bar@baz "prefix being important for all
// types.
//
@@ -292,6 +295,24 @@ int logline(char *str, struct ircdstate *ircdstate, char *basedir, int type) {
break;
+ case LOG_MODE:
+ // Extract nick from prefix
+ extractnickfromprefix(tokens[0]);
+
+ // Build a friendly message (e.g. "nick sets mode #channel +ov nick1 nick2")
+ if (!snprintf(line, MAXCHAR, "%s sets mode %s %s", tokens[0], tokens[2], str)) {
+ debugprint(DEBUG_CRIT, "logline(): Error while preparing friendly message for mode log message, returning!\n");
+ return 0;
+ }
+
+ // Build the log filename
+ if (!snprintf(filename, MAXCHAR, "%s/logs/%s.log", basedir, to)) {
+ debugprint(DEBUG_CRIT, "logline(): Error while preparing log filename for mode, returning!\n");
+ return 0;
+ }
+
+ break;
+
default :
debugprint(DEBUG_CRIT, "logline(): Unknown log type '%d', returning 0.\n", type);
return 0;
@@ -352,7 +373,8 @@ int logline(char *str, struct ircdstate *ircdstate, char *basedir, int type) {
return 0;
}
}
- } else if (type == LOG_JOINPART || type == LOG_TOPIC || type == LOG_NETWORK || type == LOG_QUIT || type == LOG_NICK) {
+ } else if (type == LOG_JOINPART || type == LOG_TOPIC || type == LOG_NETWORK ||
+ type == LOG_QUIT || type == LOG_NICK || LOG_MODE) {
// Prepend the time string
char line2[MAXCHAR];
if (!snprintf(line2, MAXCHAR, "%s %s", timestr, line)) {