diff options
Diffstat (limited to 'logging.c')
-rw-r--r-- | logging.c | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -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)) { |