summaryrefslogtreecommitdiff
path: root/logging.c
diff options
context:
space:
mode:
Diffstat (limited to 'logging.c')
-rw-r--r--logging.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/logging.c b/logging.c
index f6fa23e..6935673 100644
--- a/logging.c
+++ b/logging.c
@@ -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)) {