diff options
author | Luke Bratch <luke@bratch.co.uk> | 2019-09-15 15:11:55 +0100 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2019-09-15 15:11:55 +0100 |
commit | aab7a7000cff14afe4cb331721ad55dc139f80c7 (patch) | |
tree | c6b5d7a9dd4d39fdc6dba08005267a209a3ec154 /logging.c | |
parent | e9d4ad3c33b81ff56c4e4b2cac4aad559a303104 (diff) |
Log nick changes to the normal log file(s).
Diffstat (limited to 'logging.c')
-rw-r--r-- | logging.c | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -48,6 +48,10 @@ // channel log file. The caller probably has to call logline() // multiple times for each channel the nick was in. // +// If LOG_NICK then it expects a string in the format: +// :oldnick!bar@baz NICK :newnick +// Same manual 'channelname' prepending as LOG_QUIT above. +// // With the ":foo!bar@baz "prefix being important for all // types. // @@ -263,6 +267,23 @@ int logline(char *str, struct ircdstate *ircdstate, char *basedir, int type) { break; + case LOG_NICK: + // Extract old nick from the prefix + extractnickfromprefix(tokens[1]); + // Strip colon from new nick + stripprefix(str); + + // Build a friendly message (e.g. "oldnick is now known as newnick") + snprintf(line, MAXCHAR, "%s is now known as %s", tokens[1], str); + + // Build the log filename + if (!snprintf(filename, MAXCHAR, "%s/logs/%s.log", basedir, tokens[0])) { + debugprint(DEBUG_CRIT, "logline(): Error while preparing log filename for nick, returning!\n"); + return 0; + } + + break; + default : debugprint(DEBUG_CRIT, "logline(): Unknown log type '%d', returning 0.\n", type); return 0; @@ -323,7 +344,7 @@ 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) { + } else if (type == LOG_JOINPART || type == LOG_TOPIC || type == LOG_NETWORK || type == LOG_QUIT || type == LOG_NICK) { // Prepend the time string char line2[MAXCHAR]; if (!snprintf(line2, MAXCHAR, "%s %s", timestr, line)) { |