Commit a227b3f8 a227b3f8a8704188ea460f7550e50fbfab3d5221 by Sergey Poznyakoff

* include/mailutils/gocs.h (log_facility): Remove.

* include/mailutils/syslog.h (mu_log_facility, mu_log_tag): New
declarations.
(MU_LOG_TAG): New define.
* mailbox/gocs.c (mu_gocs_logging_init): Set mu_log_tag.
* mailbox/syslog.c (mu_log_facility, mu_log_tag): New variables.
* libcfg/common.c (mu_logging_param): New statement `tag'.
* comsat/comsat.c, imap4d/imap4d.c, imap4d/login.c,
maidag/maidag.c, mail.local/main.c, pop3d/pop3d.c, pop3d/user.c,
sieve/sieve.c: Use MU_LOG_TAG in openlog, and
program_version in mu_m_server_create calls.
1 parent 1413c3ce
2008-01-14 Sergey Poznyakoff <gray@gnu.org.ua>
* include/mailutils/gocs.h (log_facility): Remove.
* include/mailutils/syslog.h (mu_log_facility, mu_log_tag): New
declarations.
(MU_LOG_TAG): New define.
* mailbox/gocs.c (mu_gocs_logging_init): Set mu_log_tag.
* mailbox/syslog.c (mu_log_facility, mu_log_tag): New variables.
* libcfg/common.c (mu_logging_param): New statement `tag'.
* comsat/comsat.c, imap4d/imap4d.c, imap4d/login.c,
maidag/maidag.c, mail.local/main.c, pop3d/pop3d.c, pop3d/user.c,
sieve/sieve.c: Use MU_LOG_TAG in openlog, and
program_version in mu_m_server_create calls.
* libsieve/conf.c (mu_sieve_module_init): Remove initial call to
_path_append.
* libsieve/load.c (sieve_init_load_path): New function.
......
......@@ -570,7 +570,7 @@ main (int argc, char **argv)
comsat_init ();
mu_acl_cfg_init ();
mu_m_server_cfg_init ();
mu_m_server_create (&server, "GNU comsat");
mu_m_server_create (&server, program_version);
mu_m_server_set_type (server, MU_IP_UDP);
mu_m_server_set_conn (server, comsat_connection);
mu_m_server_set_prefork (server, comsat_prefork);
......@@ -618,7 +618,7 @@ main (int argc, char **argv)
}
/* Set up error messaging */
openlog ("gnu-comsat", LOG_PID, log_facility);
openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility);
{
mu_debug_t debug;
......
......@@ -482,7 +482,7 @@ main (int argc, char **argv)
mu_argp_init (program_version, NULL);
mu_m_server_create (&server, "GNU imap4d");
mu_m_server_create (&server, program_version);
mu_m_server_set_conn (server, imap4d_connection);
mu_m_server_set_prefork (server, mu_tcp_wrapper_prefork);
mu_m_server_set_mode (server, MODE_INTERACTIVE);
......@@ -542,7 +542,7 @@ main (int argc, char **argv)
signal (SIGABRT, imap4d_signal);
/* Set up for syslog. */
openlog ("gnu-imap4d", LOG_PID, log_facility);
openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility);
/* Redirect any stdout error from the library to syslog, they
should not go to the client. */
......
......@@ -49,7 +49,7 @@ imap4d_login (struct imap4d_command *command, char *arg)
}
rc = mu_authenticate (auth_data, pass);
openlog ("gnu-imap4d", LOG_PID, log_facility);
openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility);
if (rc)
{
mu_diag_output (MU_DIAG_INFO, _("Login failed: %s"), username);
......
......@@ -21,6 +21,7 @@
#include <mailutils/types.h>
#include <mailutils/list.h>
#include <mailutils/syslog.h>
#ifdef __cplusplus
extern "C" {
......@@ -81,9 +82,6 @@ extern int mu_load_user_rcfile;
extern int mu_load_site_rcfile;
extern char *mu_load_rcfile;
extern int log_facility; /* FIXME: 1. Belongs elsewhere;
2. Does not begin with `mu_' */
typedef int (*gocs_init_fp) (void *data);
void mu_gocs_register (const char *capa, gocs_init_fp init);
......
......@@ -25,6 +25,10 @@
extern "C" {
#endif
extern int mu_log_facility;
extern char *mu_log_tag;
#define MU_LOG_TAG() (mu_log_tag ? mu_log_tag : mu_program_name)
int mu_string_to_syslog_facility (char *str, int *pfacility);
const char *mu_syslog_facility_to_string (int n);
int mu_string_to_syslog_priority (char *str, int *pprio);
......
......@@ -144,6 +144,8 @@ static struct mu_cfg_param mu_logging_param[] = {
N_("Set syslog facility. Arg is one of the following: user, daemon, "
"auth, authpriv, mail, cron, local0 through local7 (case-insensitive), "
"or a facility number.") },
{ "tag", mu_cfg_string, &mu_log_tag, 0, NULL,
N_("Tag syslog messages with this string.") },
{ NULL }
};
......
......@@ -476,7 +476,7 @@ main (int argc, char *argv[])
/* Parse command line */
mu_argp_init (program_version, NULL);
mu_m_server_create (&server, "GNU maidag");
mu_m_server_create (&server, program_version);
mu_m_server_set_conn (server, lmtp_connection);
mu_m_server_set_prefork (server, mu_tcp_wrapper_prefork);
mu_m_server_set_mode (server, MODE_INTERACTIVE);
......@@ -496,7 +496,7 @@ main (int argc, char *argv[])
{
mu_debug_t debug;
openlog ("maidag", LOG_PID, log_facility);
openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility);
mu_diag_get_debug (&debug);
mu_debug_set_print (debug, mu_diag_syslog_printer, NULL);
......
......@@ -398,8 +398,7 @@ main (int argc, char *argv[])
if (uid == 0)
{
mu_debug_t debug;
openlog ("mail.local", LOG_PID, log_facility);
openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility);
mu_diag_get_debug (&debug);
mu_debug_set_print (debug, mu_diag_syslog_printer, NULL);
}
......
......@@ -31,6 +31,7 @@
#include <mailutils/errno.h>
#include <mailutils/nls.h>
#include <mailutils/debug.h>
#include <mailutils/syslog.h>
#include <syslog.h>
int mu_load_user_rcfile = 1;
......@@ -216,12 +217,14 @@ mu_gocs_logging_init (void *data)
if (p->facility)
{
log_facility = p->facility;
mu_log_facility = p->facility;
mu_debug_default_printer = mu_debug_syslog_printer;
}
else
mu_debug_default_printer = mu_debug_stderr_printer;
if (p->tag)
mu_log_tag = strdup (p->tag);
/* FIXME: Tag */
return 0;
}
......
......@@ -135,4 +135,5 @@ mu_diag_syslog_printer (void *data, mu_log_level_t level, const char *buf)
}
int log_facility = LOG_FACILITY;
int mu_log_facility = LOG_FACILITY;
char *mu_log_tag = NULL;
......
......@@ -478,7 +478,7 @@ main (int argc, char **argv)
mu_argp_init (program_version, NULL);
mu_m_server_create (&server, "GNU pop3d");
mu_m_server_create (&server, program_version);
mu_m_server_set_conn (server, pop3d_connection);
mu_m_server_set_prefork (server, mu_tcp_wrapper_prefork);
mu_m_server_set_mode (server, MODE_INTERACTIVE);
......@@ -533,7 +533,7 @@ main (int argc, char **argv)
signal (SIGABRT, pop3d_signal);
/* Set up for syslog. */
openlog ("gnu-pop3d", LOG_PID, log_facility);
openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility);
/* Redirect any stdout error from the library to syslog, they
should not go to the client. */
{
......
......@@ -146,7 +146,7 @@ pop3d_user (const char *arg)
}
rc = mu_authenticate (auth_data, pass);
openlog ("gnu-pop3d", LOG_PID, log_facility);
openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility);
if (rc)
{
......
......@@ -384,7 +384,7 @@ main (int argc, char *argv[])
tickets = mu_tilde_expansion ("~/.tickets", "/", NULL);
tickets_default = 1;
debug_level = MU_DEBUG_LEVEL_MASK (MU_DEBUG_ERROR);
log_facility = 0;
mu_log_facility = 0;
if (mu_app_init (&argp, sieve_argp_capa, sieve_cfg_param,
argc, argv, ARGP_IN_ORDER, NULL, NULL))
......@@ -398,12 +398,12 @@ main (int argc, char *argv[])
return 1;
}
if (log_facility)
if (mu_log_facility)
{
mu_debug_t debug;
mu_diag_get_debug (&debug);
openlog ("sieve", LOG_PID, log_facility);
openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility);
mu_debug_set_print (debug, mu_diag_syslog_printer, NULL);
}
......