From acc50df0efef8bd9fa937a5d640314c0e78e9117 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 3 Jan 2020 18:50:33 +0100 Subject: Fix logging environment constants (#2745) * Fix logging environment constants * COPY_LOG_TO_SYSLOG was only working when Syslog was used * FRESHRSS_ENV was not properly used to set logging level * Simplify code Always call `openlog()` even when it is not used * Always specify syslog properties https://github.com/FreshRSS/FreshRSS/pull/2745#discussion_r362207445 * $username is also needed further down * No new line in syslog --- lib/lib_rss.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib/lib_rss.php') diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 357c02e82..1060ef5c5 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -9,6 +9,12 @@ if (!function_exists('mb_strcut')) { } } +if (COPY_SYSLOG_TO_STDERR) { + openlog('FreshRSS', LOG_CONS | LOG_ODELAY | LOG_PID | LOG_PERROR, LOG_USER); +} else { + openlog('FreshRSS', LOG_CONS | LOG_ODELAY | LOG_PID, LOG_USER); +} + /** * Build a directory path by concatenating a list of directory names. * @@ -188,19 +194,12 @@ function html_only_entity_decode($text) { return strtr($text, $htmlEntitiesOnly); } -function prepareSyslog() { - return COPY_SYSLOG_TO_STDERR ? openlog("FreshRSS", LOG_PERROR | LOG_PID, LOG_USER) : false; -} - function customSimplePie($attributes = array()) { $system_conf = Minz_Configuration::get('system'); $limits = $system_conf->limits; $simplePie = new SimplePie(); $simplePie->set_useragent(FRESHRSS_USERAGENT); $simplePie->set_syslog($system_conf->simplepie_syslog_enabled); - if ($system_conf->simplepie_syslog_enabled) { - prepareSyslog(); - } $simplePie->set_cache_location(CACHE_PATH); $simplePie->set_cache_duration($limits['cache_duration']); -- cgit v1.2.3