Commit 759110ea authored by Guillaume Rousse's avatar Guillaume Rousse

init syslog only once

parent d316ba92
...@@ -74,6 +74,10 @@ $verbose = isset($options['verbose']) || isset($options['v']) ? true : false; ...@@ -74,6 +74,10 @@ $verbose = isset($options['verbose']) || isset($options['v']) ? true : false;
$syslog = isset($options['syslog']) ? true : false; $syslog = isset($options['syslog']) ? true : false;
$syslogId = isset($options['syslog-id']) ? $options['syslog-id'] : 'switchwayf'; $syslogId = isset($options['syslog-id']) ? $options['syslog-id'] : 'switchwayf';
if ($syslog) {
openlog($syslogId, LOG_NDELAY, LOG_USER);
}
if (isset($options['metadata-url'])) { if (isset($options['metadata-url'])) {
$metadataURL = $options['metadata-url']; $metadataURL = $options['metadata-url'];
} elseif (isset($options['metadata-file'])) { } elseif (isset($options['metadata-file'])) {
...@@ -226,10 +230,9 @@ if ($metadataURL) { ...@@ -226,10 +230,9 @@ if ($metadataURL) {
} }
function reportError($message) { function reportError($message) {
global $syslog, $syslogId; global $syslog;
if ($syslog) { if ($syslog) {
openlog($syslogId, LOG_NDELAY, LOG_USER);
syslog(LOG_ERR, $message); syslog(LOG_ERR, $message);
} else { } else {
fwrite(STDERR, $message); fwrite(STDERR, $message);
...@@ -237,10 +240,9 @@ function reportError($message) { ...@@ -237,10 +240,9 @@ function reportError($message) {
} }
function reportInfo($message) { function reportInfo($message) {
global $syslog, $syslogId; global $syslog;
if ($syslog) { if ($syslog) {
openlog($syslogId, LOG_NDELAY, LOG_USER);
syslog(LOG_INFO, $message); syslog(LOG_INFO, $message);
} else { } else {
fwrite(STDOUT, $message); fwrite(STDOUT, $message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment