[LOG] Fixup log_beautify to work beautifully :)
This commit is contained in:
parent
a5814b17a0
commit
8ed0565266
47
src/log.c
47
src/log.c
@ -789,7 +789,8 @@ chan:
|
|||||||
09-01-2009 14:15:57 > bip4ever: chantest
|
09-01-2009 14:15:57 > bip4ever: chantest
|
||||||
09-01-2009 14:16:21 < nohar!~nohar@haruka.t1r.net: chantestrepl
|
09-01-2009 14:16:21 < nohar!~nohar@haruka.t1r.net: chantestrepl
|
||||||
*/
|
*/
|
||||||
char *log_beautify(log_t *logdata, const char *buf, const char *dest)
|
char *log_beautify(log_t *logdata, const char *buf, const char *storename,
|
||||||
|
const char *dest)
|
||||||
{
|
{
|
||||||
int action = 0;
|
int action = 0;
|
||||||
char *p;
|
char *p;
|
||||||
@ -797,8 +798,8 @@ char *log_beautify(log_t *logdata, const char *buf, const char *dest)
|
|||||||
* so = startov, lo = lengthov
|
* so = startov, lo = lengthov
|
||||||
* ts = timestamp, n = sender nick, m = message or action
|
* ts = timestamp, n = sender nick, m = message or action
|
||||||
*/
|
*/
|
||||||
const char *sots, *son, *som, *sod = NULL;
|
const char *sots, *son, *som;
|
||||||
size_t lots, lon, lom, lod;
|
size_t lots, lon, lom;
|
||||||
char *ret;
|
char *ret;
|
||||||
int out;
|
int out;
|
||||||
int done;
|
int done;
|
||||||
@ -849,9 +850,11 @@ char *log_beautify(log_t *logdata, const char *buf, const char *dest)
|
|||||||
lon = p - son;
|
lon = p - son;
|
||||||
|
|
||||||
p = strchr(p, ' ');
|
p = strchr(p, ' ');
|
||||||
if (!p || !p[0])
|
if (!p || !p[0] || !p[1])
|
||||||
return _log_wrap(dest, buf);
|
return _log_wrap(dest, buf);
|
||||||
|
p++;
|
||||||
|
|
||||||
|
#if 0
|
||||||
done = ((p[-1] == ':') || (action && (p[1] != '(')));
|
done = ((p[-1] == ':') || (action && (p[1] != '(')));
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
@ -881,21 +884,11 @@ char *log_beautify(log_t *logdata, const char *buf, const char *dest)
|
|||||||
sod = dest;
|
sod = dest;
|
||||||
lod = strlen(dest);
|
lod = strlen(dest);
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
if (out && !ischannel(*dest)) {
|
|
||||||
const char *stmp;
|
|
||||||
size_t ltmp;
|
|
||||||
|
|
||||||
stmp = sod;
|
|
||||||
ltmp = lod;
|
|
||||||
|
|
||||||
sod = son;
|
|
||||||
lod = lon;
|
|
||||||
|
|
||||||
son = stmp;
|
|
||||||
lon = ltmp;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
if (out && !ischannel(*dest)) {
|
||||||
|
son = storename;
|
||||||
|
lon = strlen(storename);
|
||||||
|
}
|
||||||
|
|
||||||
som = p;
|
som = p;
|
||||||
lom = strlen(p);
|
lom = strlen(p);
|
||||||
@ -903,8 +896,9 @@ char *log_beautify(log_t *logdata, const char *buf, const char *dest)
|
|||||||
return _log_wrap(dest, buf);
|
return _log_wrap(dest, buf);
|
||||||
|
|
||||||
p = ret = (char *)bip_malloc(
|
p = ret = (char *)bip_malloc(
|
||||||
1 + lon + strlen(LAMESTRING) + lod + 2 + lots + 2 + lom + 3
|
1 + lon + strlen(LAMESTRING) + strlen(dest) + 2 + lots + 2 +
|
||||||
+ action * (2 + strlen("ACTION ")) + out * strlen(PMSG_ARROW));
|
lom + 3 + action * (2 + strlen("ACTION ")) +
|
||||||
|
out * strlen(PMSG_ARROW));
|
||||||
|
|
||||||
*p++ = ':';
|
*p++ = ':';
|
||||||
|
|
||||||
@ -914,8 +908,10 @@ char *log_beautify(log_t *logdata, const char *buf, const char *dest)
|
|||||||
strcpy(p, LAMESTRING);
|
strcpy(p, LAMESTRING);
|
||||||
p += strlen(LAMESTRING);
|
p += strlen(LAMESTRING);
|
||||||
|
|
||||||
memcpy(p, sod, lod);
|
memcpy(p, dest, strlen(dest));
|
||||||
p += lod;
|
p += strlen(dest);
|
||||||
|
//memcpy(p, sod, lod);
|
||||||
|
//p += lod;
|
||||||
|
|
||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
*p++ = ':';
|
*p++ = ':';
|
||||||
@ -925,7 +921,7 @@ char *log_beautify(log_t *logdata, const char *buf, const char *dest)
|
|||||||
strcpy(p, "ACTION ");
|
strcpy(p, "ACTION ");
|
||||||
p += strlen("ACTION ");
|
p += strlen("ACTION ");
|
||||||
}
|
}
|
||||||
if (out) {
|
if (out && !ischannel(*dest)) {
|
||||||
strcpy(p, PMSG_ARROW);
|
strcpy(p, PMSG_ARROW);
|
||||||
p += strlen(PMSG_ARROW);
|
p += strlen(PMSG_ARROW);
|
||||||
}
|
}
|
||||||
@ -1004,7 +1000,7 @@ static int log_backread_file(log_t *log, logstore_t *store, logfile_t *lf,
|
|||||||
if (buf[0] == 0 || buf[0] == '\n')
|
if (buf[0] == 0 || buf[0] == '\n')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
logbr = log_beautify(log, buf, dest);
|
logbr = log_beautify(log, buf, store->name, dest);
|
||||||
if (logbr)
|
if (logbr)
|
||||||
list_add_last(res, logbr);
|
list_add_last(res, logbr);
|
||||||
|
|
||||||
@ -1089,7 +1085,8 @@ static int _log_write(log_t *logdata, logstore_t *store,
|
|||||||
tmpstr[LOGLINE_MAXLEN] = 0;
|
tmpstr[LOGLINE_MAXLEN] = 0;
|
||||||
|
|
||||||
if (store->memlog) {
|
if (store->memlog) {
|
||||||
char *r = log_beautify(logdata, tmpstr, destination);
|
char *r = log_beautify(logdata, tmpstr, store->name,
|
||||||
|
destination);
|
||||||
if (r != NULL) {
|
if (r != NULL) {
|
||||||
list_add_last(store->memlog, r);
|
list_add_last(store->memlog, r);
|
||||||
if (store->memc == logdata->user->backlog_lines)
|
if (store->memc == logdata->user->backlog_lines)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user