dovecot-2.0: Log paths now support "syslog" string.
dovecot at dovecot.org
dovecot at dovecot.org
Wed Jun 16 19:38:19 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/3edf323da761
changeset: 11557:3edf323da761
user: Timo Sirainen <tss at iki.fi>
date: Wed Jun 16 17:38:15 2010 +0100
description:
Log paths now support "syslog" string.
diffstat:
src/doveadm/doveadm-log.c | 27 ++++++++-----
src/lib-master/master-service-settings.c | 23 ++++++++++-
src/lib-master/master-service.c | 40 ++++++++++++++------
3 files changed, 66 insertions(+), 24 deletions(-)
diffs (153 lines):
diff -r dd1f0a7127a9 -r 3edf323da761 src/doveadm/doveadm-log.c
--- a/src/doveadm/doveadm-log.c Wed Jun 16 17:37:00 2010 +0100
+++ b/src/doveadm/doveadm-log.c Wed Jun 16 17:38:15 2010 +0100
@@ -218,23 +218,30 @@
/* first get the paths that we know are used */
set = master_service_settings_get(master_service);
log_file_path = set->log_path;
- if (*log_file_path != '\0') {
+ if (*log_file_path != '\0' && strcmp(log_file_path, "syslog") != 0) {
cmd_log_find_add(&ctx, log_file_path, LOG_TYPE_WARNING);
cmd_log_find_add(&ctx, log_file_path, LOG_TYPE_ERROR);
cmd_log_find_add(&ctx, log_file_path, LOG_TYPE_FATAL);
}
- if (*set->info_log_path != '\0')
- log_file_path = set->info_log_path;
- if (*log_file_path != '\0')
- cmd_log_find_add(&ctx, log_file_path, LOG_TYPE_INFO);
+ if (strcmp(set->info_log_path, "syslog") != 0) {
+ if (*set->info_log_path != '\0')
+ log_file_path = set->info_log_path;
+ if (*log_file_path != '\0')
+ cmd_log_find_add(&ctx, log_file_path, LOG_TYPE_INFO);
+ }
- if (*set->debug_log_path != '\0')
- log_file_path = set->debug_log_path;
- if (*log_file_path != '\0')
- cmd_log_find_add(&ctx, log_file_path, LOG_TYPE_DEBUG);
+ if (strcmp(set->debug_log_path, "syslog") != 0) {
+ if (*set->debug_log_path != '\0')
+ log_file_path = set->debug_log_path;
+ if (*log_file_path != '\0')
+ cmd_log_find_add(&ctx, log_file_path, LOG_TYPE_DEBUG);
+ }
- if (*set->log_path == '\0') {
+ if (*set->log_path == '\0' ||
+ strcmp(set->log_path, "syslog") == 0 ||
+ strcmp(set->info_log_path, "syslog") == 0 ||
+ strcmp(set->debug_log_path, "syslog") == 0) {
/* at least some logs were logged via syslog */
cmd_log_find_syslog(&ctx, argc, argv);
}
diff -r dd1f0a7127a9 -r 3edf323da761 src/lib-master/master-service-settings.c
--- a/src/lib-master/master-service-settings.c Wed Jun 16 17:37:00 2010 +0100
+++ b/src/lib-master/master-service-settings.c Wed Jun 16 17:38:15 2010 +0100
@@ -27,6 +27,9 @@
#define DEF(type, name) \
{ type, #name, offsetof(struct master_service_settings, name), NULL }
+static bool
+master_service_settings_check(void *_set, pool_t pool, const char **error_r);
+
static const struct setting_define master_service_setting_defines[] = {
DEF(SET_STR, log_path),
DEF(SET_STR, info_log_path),
@@ -41,7 +44,7 @@
};
static const struct master_service_settings master_service_default_settings = {
- .log_path = "",
+ .log_path = "syslog",
.info_log_path = "",
.debug_log_path = "",
.log_timestamp = DEFAULT_FAILURE_STAMP_FORMAT,
@@ -59,9 +62,25 @@
.type_offset = (size_t)-1,
.struct_size = sizeof(struct master_service_settings),
- .parent_offset = (size_t)-1
+ .parent_offset = (size_t)-1,
+ .check_func = master_service_settings_check
};
+/* <settings checks> */
+static bool
+master_service_settings_check(void *_set, pool_t pool ATTR_UNUSED,
+ const char **error_r ATTR_UNUSED)
+{
+ struct master_service_settings *set = _set;
+
+ if (*set->log_path == '\0') {
+ /* default to syslog logging */
+ set->log_path = "syslog";
+ }
+ return TRUE;
+}
+/* </settings checks> */
+
static void ATTR_NORETURN
master_service_exec_config(struct master_service *service,
const struct master_service_settings_input *input)
diff -r dd1f0a7127a9 -r 3edf323da761 src/lib-master/master-service.c
--- a/src/lib-master/master-service.c Wed Jun 16 17:37:00 2010 +0100
+++ b/src/lib-master/master-service.c Wed Jun 16 17:38:15 2010 +0100
@@ -214,8 +214,16 @@
return;
}
- if (*service->set->log_path == '\0') {
- /* log to syslog */
+ if (strcmp(service->set->log_path, "syslog") != 0) {
+ /* error logging goes to file or stderr */
+ path = home_expand(service->set->log_path);
+ i_set_failure_file(path, prefix);
+ }
+
+ if (strcmp(service->set->log_path, "syslog") == 0 ||
+ strcmp(service->set->info_log_path, "syslog") == 0 ||
+ strcmp(service->set->debug_log_path, "syslog") == 0) {
+ /* something gets logged to syslog */
int facility;
if (!syslog_facility_find(service->set->syslog_facility,
@@ -223,19 +231,27 @@
facility = LOG_MAIL;
i_set_failure_syslog("dovecot", LOG_NDELAY, facility);
i_set_failure_prefix(prefix);
- } else {
- /* log to file or stderr */
- path = home_expand(service->set->log_path);
- i_set_failure_file(path, prefix);
+
+ if (strcmp(service->set->log_path, "syslog") != 0) {
+ /* set error handlers back to file */
+ i_set_fatal_handler(NULL);
+ i_set_error_handler(NULL);
+ }
}
- path = home_expand(service->set->info_log_path);
- if (*path != '\0')
- i_set_info_file(path);
+ if (*service->set->info_log_path != '\0' &&
+ strcmp(service->set->info_log_path, "syslog") != 0) {
+ path = home_expand(service->set->info_log_path);
+ if (*path != '\0')
+ i_set_info_file(path);
+ }
- path = home_expand(service->set->debug_log_path);
- if (*path != '\0')
- i_set_debug_file(path);
+ if (*service->set->debug_log_path != '\0' &&
+ strcmp(service->set->debug_log_path, "syslog") != 0) {
+ path = home_expand(service->set->debug_log_path);
+ if (*path != '\0')
+ i_set_debug_file(path);
+ }
i_set_failure_timestamp_format(service->set->log_timestamp);
}
More information about the dovecot-cvs
mailing list