backlog enhancement + verbosification fix
This commit is contained in:
parent
103a9f0369
commit
e9884c5b03
35
src/log.c
35
src/log.c
@ -404,16 +404,21 @@ void log_privmsg(log_t *logdata, char *ircmask, char *destination,
|
|||||||
log_write(logdata, destination, logdata->buffer);
|
log_write(logdata, destination, logdata->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_notice(log_t *logdata, char *ircmask, char *channel,
|
void log_notice(log_t *logdata, char *ircmask, char *destination, char *message)
|
||||||
char *message)
|
|
||||||
{
|
{
|
||||||
if (!ircmask)
|
if (!ircmask)
|
||||||
ircmask = "Server message";
|
ircmask = "Server message";
|
||||||
if (*message == '\001' && *(message + strlen(message) - 1) == '\001')
|
if (*message == '\001' && *(message + strlen(message) - 1) == '\001')
|
||||||
return;
|
return;
|
||||||
snprintf(logdata->buffer, LOGLINE_MAXLEN, "%s %s: %s %s\n", timestamp(),
|
if (ischannel(*destination) || strchr(destination, '@')) {
|
||||||
ircmask, channel, message);
|
snprintf(logdata->buffer, LOGLINE_MAXLEN, "%s %s: %s\n",
|
||||||
log_write(logdata, channel, logdata->buffer);
|
timestamp(), ircmask, message);
|
||||||
|
} else {
|
||||||
|
snprintf(logdata->buffer, LOGLINE_MAXLEN,
|
||||||
|
"%s %s (%s): %s\n", timestamp(),
|
||||||
|
ircmask, destination, message);
|
||||||
|
}
|
||||||
|
log_write(logdata, destination, logdata->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_topic(log_t *logdata, char *ircmask, char *channel, char *message)
|
void log_topic(log_t *logdata, char *ircmask, char *channel, char *message)
|
||||||
@ -612,7 +617,7 @@ static char *log_beautify(char *buf, char *dest, int *raw)
|
|||||||
char *sots, *son, *som, *sod = NULL;
|
char *sots, *son, *som, *sod = NULL;
|
||||||
size_t lots, lon, lom, lod;
|
size_t lots, lon, lom, lod;
|
||||||
char *ret;
|
char *ret;
|
||||||
|
int guess_was_me = 0;
|
||||||
|
|
||||||
*raw = 0;
|
*raw = 0;
|
||||||
if (!buf)
|
if (!buf)
|
||||||
@ -640,6 +645,8 @@ static char *log_beautify(char *buf, char *dest, int *raw)
|
|||||||
/* 'date time blawithnoexcl bla bla ! bla' --> ? */
|
/* 'date time blawithnoexcl bla bla ! bla' --> ? */
|
||||||
while (*p && *p != '!' && *p != ' ' && *p != ':')
|
while (*p && *p != '!' && *p != ' ' && *p != ':')
|
||||||
p++;
|
p++;
|
||||||
|
if (*p != '!')
|
||||||
|
guess_was_me = 1;
|
||||||
if (!p[0] || !p[1])
|
if (!p[0] || !p[1])
|
||||||
return buf;
|
return buf;
|
||||||
lon = p - son;
|
lon = p - son;
|
||||||
@ -649,6 +656,9 @@ static char *log_beautify(char *buf, char *dest, int *raw)
|
|||||||
p++;
|
p++;
|
||||||
|
|
||||||
if (*p == '(') {
|
if (*p == '(') {
|
||||||
|
p++;
|
||||||
|
if (!p[0] || !p[1] || p[0] == ')')
|
||||||
|
return buf;
|
||||||
sod = p;
|
sod = p;
|
||||||
while (*p && *p != ')' && *p != ' ')
|
while (*p && *p != ')' && *p != ' ')
|
||||||
p++;
|
p++;
|
||||||
@ -668,7 +678,10 @@ static char *log_beautify(char *buf, char *dest, int *raw)
|
|||||||
sod = dest;
|
sod = dest;
|
||||||
lod = strlen(dest);
|
lod = strlen(dest);
|
||||||
}
|
}
|
||||||
|
if (guess_was_me) {
|
||||||
|
lon = lod;
|
||||||
|
son = sod;
|
||||||
|
}
|
||||||
|
|
||||||
som = p;
|
som = p;
|
||||||
lom = strlen(p);
|
lom = strlen(p);
|
||||||
@ -676,7 +689,7 @@ static char *log_beautify(char *buf, char *dest, int *raw)
|
|||||||
*raw = 1;
|
*raw = 1;
|
||||||
p = ret = (char *)malloc(
|
p = ret = (char *)malloc(
|
||||||
1 + lon + strlen(LAMESTRING) + lod + 2 + lots +
|
1 + lon + strlen(LAMESTRING) + lod + 2 + lots +
|
||||||
1 + lom + 3 + action * (2 + strlen("ACTION ")));
|
1 + 3 + lom + 3 + action * (2 + strlen("ACTION ")));
|
||||||
if (!p)
|
if (!p)
|
||||||
fatal("out of memory");
|
fatal("out of memory");
|
||||||
*p++ = ':';
|
*p++ = ':';
|
||||||
@ -698,6 +711,10 @@ static char *log_beautify(char *buf, char *dest, int *raw)
|
|||||||
memcpy(p, "ACTION ", strlen("ACTION "));
|
memcpy(p, "ACTION ", strlen("ACTION "));
|
||||||
p += strlen("ACTION ");
|
p += strlen("ACTION ");
|
||||||
}
|
}
|
||||||
|
if (guess_was_me) {
|
||||||
|
memcpy(p, "<-", 2);
|
||||||
|
p += 2;
|
||||||
|
}
|
||||||
memcpy(p, sots, lots);
|
memcpy(p, sots, lots);
|
||||||
p += lots;
|
p += lots;
|
||||||
|
|
||||||
@ -711,9 +728,9 @@ static char *log_beautify(char *buf, char *dest, int *raw)
|
|||||||
*p++ = '\r';
|
*p++ = '\r';
|
||||||
*p++ = '\n';
|
*p++ = '\n';
|
||||||
*p = 0;
|
*p = 0;
|
||||||
free(buf);
|
|
||||||
mylog(LOG_INFO, "beautify in: \"%s\"", buf);
|
mylog(LOG_INFO, "beautify in: \"%s\"", buf);
|
||||||
mylog(LOG_INFO, "beautify out: \"%s\"", ret);
|
mylog(LOG_INFO, "beautify out: \"%s\"", ret);
|
||||||
|
free(buf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user