return -1;
}
+ fpm_stdio_init_final();
zlog(ZLOG_NOTICE, "fpm is running, pid %d", (int) fpm_globals.parent_pid);
return 0;
int fpm_stdio_init_final() /* {{{ */
{
- zlog_set_level(fpm_globals.log_level);
if (fpm_global_config.daemonize) {
if (fpm_globals.error_log_fd != STDERR_FILENO) {
/* there might be messages to stderr from libevent, we need to log them all */
return -1;
}
}
- zlog_set_fd(fpm_globals.error_log_fd);
}
+ zlog_set_launched();
return 0;
}
/* }}} */
fd = fpm_globals.error_log_fd; /* for FD_CLOSEXEC to work */
} else {
fpm_globals.error_log_fd = fd;
+ if (fpm_global_config.daemonize) {
+ zlog_set_fd(fpm_globals.error_log_fd);
+ }
}
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
return 0;
}
}
- fpm_stdio_init_final();
+ zlog_set_level(fpm_globals.log_level);
return 0;
}
/* }}} */
static int zlog_fd = -1;
static int zlog_level = ZLOG_NOTICE;
+static int launched = 0;
static const char *level_names[] = {
[ZLOG_DEBUG] = "DEBUG",
[ZLOG_ALERT] = "ALERT",
};
+void zlog_set_launched(void) {
+ launched = 1;
+}
+
size_t zlog_print_time(struct timeval *tv, char *timebuf, size_t timebuf_len) /* {{{ */
{
struct tm t;
buf[len++] = '\n';
write(zlog_fd > -1 ? zlog_fd : STDERR_FILENO, buf, len);
+ if (zlog_fd != STDERR_FILENO && zlog_fd > -1 && !launched && (flags & ZLOG_LEVEL_MASK) >= ZLOG_WARNING) {
+ write(STDERR_FILENO, buf, len);
+ }
}
/* }}} */
int zlog_set_fd(int new_fd);
int zlog_set_level(int new_value);
+void zlog_set_launched(void);
size_t zlog_print_time(struct timeval *tv, char *timebuf, size_t timebuf_len);