diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-12-22 01:32:18 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-12-22 01:32:18 +0300 |
commit | e413f4ee9cd298baab701df31ab4c1cb91c7c4b6 (patch) | |
tree | 46858bef680c8a09b6d1d58a5ca7e3a8cec4e62d /src/buffer.c | |
parent | a079dac866ac4e166a8d6e40f978af74e8398583 (diff) | |
download | rspamd-e413f4ee9cd298baab701df31ab4c1cb91c7c4b6.tar.gz rspamd-e413f4ee9cd298baab701df31ab4c1cb91c7c4b6.zip |
* Introduce new logging system:
- independent and customizeable buffering
- line buffering
- errors handling support
- custom (ip based) debug
- append function name automaticaly (based on __FUNCTION__)
- add some logic to logs system
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/buffer.c b/src/buffer.c index ac0c43e21..1749cb624 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -70,7 +70,7 @@ write_buffers (int fd, rspamd_io_dispatcher_t * d, gboolean is_delayed) buf->pos += r; if (BUFREMAIN (buf) != 0) { /* Continue with this buffer */ - msg_debug ("write_buffers: wrote %z bytes of %z", r, buf->data->len); + debug_ip (d->peer_addr, "wrote %z bytes of %z", r, buf->data->len); continue; } } @@ -83,7 +83,7 @@ write_buffers (int fd, rspamd_io_dispatcher_t * d, gboolean is_delayed) } } else if (r == -1 && errno == EAGAIN) { - msg_debug ("write_buffers: partially write data, retry"); + debug_ip (d->peer_addr, "partially write data, retry"); /* Wait for other event */ event_del (d->ev); event_set (d->ev, fd, EV_WRITE, dispatcher_cb, (void *)d); @@ -98,11 +98,11 @@ write_buffers (int fd, rspamd_io_dispatcher_t * d, gboolean is_delayed) g_list_free (d->out_buffers); d->out_buffers = NULL; - msg_debug ("write_buffers: all buffers were written successfully"); + debug_ip (d->peer_addr, "all buffers were written successfully"); if (is_delayed && d->write_callback) { if (!d->write_callback (d->user_data)) { - msg_debug ("write_buffers: callback set wanna_die flag, terminating"); + debug_ip (d->peer_addr, "callback set wanna_die flag, terminating"); return FALSE; } } @@ -178,14 +178,14 @@ read_buffers (int fd, rspamd_io_dispatcher_t * d, gboolean skip_read) } } else if (r == -1 && errno == EAGAIN) { - msg_debug ("read_buffers: partially read data, retry"); + debug_ip (d->peer_addr, "partially read data, retry"); return; } else { *pos += r; *len += r; } - msg_debug ("read_buffers: read %z characters, policy is %s, watermark is: %z", r, + debug_ip (d->peer_addr, "read %z characters, policy is %s, watermark is: %z", r, d->policy == BUFFER_LINE ? "LINE" : "CHARACTER", d->nchars); } @@ -218,7 +218,7 @@ read_buffers (int fd, rspamd_io_dispatcher_t * d, gboolean skip_read) *pos = b + *len; r = 0; if (d->policy != saved_policy) { - msg_debug ("read_buffers: policy changed during callback, restart buffer's processing"); + debug_ip (d->peer_addr, "policy changed during callback, restart buffer's processing"); read_buffers (fd, d, TRUE); return; } @@ -247,7 +247,7 @@ read_buffers (int fd, rspamd_io_dispatcher_t * d, gboolean skip_read) *len -= r; *pos = b + *len; if (d->policy != saved_policy) { - msg_debug ("read_buffers: policy changed during callback, restart buffer's processing"); + debug_ip (d->peer_addr, "policy changed during callback, restart buffer's processing"); read_buffers (fd, d, TRUE); return; } @@ -265,7 +265,7 @@ dispatcher_cb (int fd, short what, void *arg) rspamd_io_dispatcher_t *d = (rspamd_io_dispatcher_t *) arg; GError *err; - msg_debug ("dispatcher_cb: in dispatcher callback, what: %d, fd: %d", (int)what, fd); + debug_ip (d->peer_addr, "in dispatcher callback, what: %d, fd: %d", (int)what, fd); switch (what) { case EV_TIMEOUT: @@ -375,7 +375,7 @@ rspamd_set_dispatcher_policy (rspamd_io_dispatcher_t * d, enum io_policy policy, } } - msg_debug ("rspamd_set_dispatcher_policy: new input length watermark is %uz", d->nchars); + debug_ip (d->peer_addr, "new input length watermark is %uz", d->nchars); } gboolean @@ -402,7 +402,7 @@ rspamd_dispatcher_write (rspamd_io_dispatcher_t * d, void *data, size_t len, gbo d->out_buffers = g_list_prepend (d->out_buffers, newbuf); if (!delayed) { - msg_debug ("rspamd_dispatcher_write: plan write event"); + debug_ip (d->peer_addr, "plan write event"); return write_buffers (d->fd, d, FALSE); } return TRUE; |