Skip to content

Commit

Permalink
Workaround disabled openlog syslog (#5054)
Browse files Browse the repository at this point in the history
* Workaround disabled openlog syslog
#fix #5053
#fix #5027

* COPY_SYSLOG_TO_STDERR

* Better return

* Simplify openlog
  • Loading branch information
Alkarex committed Jan 30, 2023
1 parent 9e4b4c9 commit 4ad66c2
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions lib/lib_rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,27 @@ function str_starts_with(string $haystack, string $needle): bool {
}
}

// @phpstan-ignore-next-line
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);
if (!function_exists('syslog')) {
// @phpstan-ignore-next-line
if (COPY_SYSLOG_TO_STDERR && !defined('STDERR')) {
define('STDERR', fopen('php://stderr', 'w'));
}
function syslog(int $priority, string $message): bool {
// @phpstan-ignore-next-line
if (COPY_SYSLOG_TO_STDERR && defined('STDERR') && STDERR) {
return fwrite(STDERR, $message . "\n") != false;
}
return false;
}
}

if (function_exists('openlog')) {
// @phpstan-ignore-next-line
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);
}
}

/**
Expand Down

0 comments on commit 4ad66c2

Please sign in to comment.