/* 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);
}
#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),
};
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,
.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)
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,
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);
}