diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-04-21 09:49:41 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-04-21 09:49:41 +0000 |
commit | c2f52c26e298299d9c2e54f212aa96be99201dcb (patch) | |
tree | 619044014a38abe2e6f8597efa74bd759ff87003 /gacopyz | |
parent | f0992a40ee322ea27371ed6b81dce893cb8cd4d8 (diff) | |
download | mailfromd-c2f52c26e298299d9c2e54f212aa96be99201dcb.tar.gz mailfromd-c2f52c26e298299d9c2e54f212aa96be99201dcb.tar.bz2 |
Improve logging
git-svn-id: file:///svnroot/mailfromd/trunk@1369 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'gacopyz')
-rw-r--r-- | gacopyz/gacopyz.c | 2 | ||||
-rw-r--r-- | gacopyz/gacopyz.h | 4 | ||||
-rw-r--r-- | gacopyz/smfi.c | 22 |
3 files changed, 26 insertions, 2 deletions
diff --git a/gacopyz/gacopyz.c b/gacopyz/gacopyz.c index 5c9c991c..f61673cc 100644 --- a/gacopyz/gacopyz.c +++ b/gacopyz/gacopyz.c @@ -1399,6 +1399,8 @@ gacopyz_handle_connection(gacopyz_conn_t conn) if (conn->desc.xxfi_finish) conn->desc.xxfi_finish(); + + gacopyz_log(conn, SMI_LOG_INFO, "finishing connection"); if (!conn->foreground) { exit(0); diff --git a/gacopyz/gacopyz.h b/gacopyz/gacopyz.h index e5353199..3b2e470a 100644 --- a/gacopyz/gacopyz.h +++ b/gacopyz/gacopyz.h @@ -209,7 +209,6 @@ extern int smfi_opensocket (int); extern int smfi_register (struct smfiDesc); extern int smfi_main (void); extern int smfi_setbacklog (int); -extern int smfi_set_foreground(int val); extern int smfi_setdbg (int); extern int smfi_settimeout (time_t); extern int smfi_setconn (char *); @@ -233,6 +232,9 @@ size_t smfi_setmaxdatasize (size_t); extern int smfi_setreply (SMFICTX *, char *, char *, char *); int smfi_setmlreply (SMFICTX *, const char *, const char *, ...); +/* Extensions */ +extern int smfi_set_foreground(int val); +extern int smfi_setlogmask(int logmask); /* New API calls: */ int gacopyz_init(gacopyz_conn_t *pconn, struct smfiDesc *desc); diff --git a/gacopyz/smfi.c b/gacopyz/smfi.c index 661be1c3..72889436 100644 --- a/gacopyz/smfi.c +++ b/gacopyz/smfi.c @@ -19,6 +19,7 @@ #include <gacopyz_priv.h> static int __smfi_dbg_level = 0; +static int __smfi_logmask = 0; static time_t __smfi_timeout = 7210; static int __smfi_backlog = 1; static char *__smfi_conn = NULL; @@ -33,6 +34,23 @@ smfi_setdbg(int level) } int +smfi_setlogmask(int logmask) +{ + switch (logmask) { + case SMI_LOG_DEBUG: + case SMI_LOG_INFO: + case SMI_LOG_WARN: + case SMI_LOG_ERR: + case SMI_LOG_FATAL: + __smfi_logmask = SMI_LOG_MASK(logmask); + return MI_SUCCESS; + + default: + return MI_FAILURE; + } +} + +int smfi_settimeout(time_t to) { __smfi_timeout = to; @@ -60,11 +78,13 @@ smfi_register(struct smfiDesc desc) struct timeval t; if (gacopyz_init(&milter_conn, &desc)) return MI_FAILURE; + if (__smfi_logmask) + gacopyz_set_logmask(milter_conn, __smfi_logmask); if (__smfi_dbg_level) { int mask; gacopyz_get_logmask(milter_conn, &mask); gacopyz_set_logmask(milter_conn, - mask | SMI_LOG_MASK(SMI_LOG_DEBUG)); + mask | SMI_LOG_MASK(SMI_LOG_DEBUG)); } t.tv_usec = 0; t.tv_sec = __smfi_timeout; |