Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Remove dependency on Syslog::LOG_PERROR #17

Merged
merged 3 commits into from Dec 5, 2011
Jump to file or symbol
Failed to load files and symbols.
+17 −13
Split
@@ -39,7 +39,7 @@ class Syslog < ::Logging::Appender
# which file descriptors are allocated.
#
# LOG_PERROR Write the message to standard error output as well to
- # the system log.
+ # the system log. Not available on Solaris.
#
# LOG_PID Log the process id with each message: useful for
# identifying instantiations of daemons.
@@ -14,9 +14,9 @@ def setup
super
Logging.init
@levels = Logging::LEVELS
- @logopt = defined?(::Syslog::LOG_NDELAY) ?
- (::Syslog::LOG_PERROR | ::Syslog::LOG_NDELAY) :
- (::Syslog::LOG_PERROR)
+ @logopt = 0
+ @logopt |= ::Syslog::LOG_NDELAY if defined?(::Syslog::LOG_NDELAY)
+ @logopt |= ::Syslog::LOG_PERROR if defined?(::Syslog::LOG_PERROR)
end
def test_append
@@ -51,12 +51,14 @@ def test_append
stderr[1].close
Process.waitpid(pid)
- assert_equal("syslog_test: INFO TestLogger : <Array> #{[1,2,3,4]}\n",
- stderr[0].gets)
- assert_equal("syslog_test: DEBUG TestLogger : the big log message\n",
- stderr[0].gets)
- assert_equal("syslog_test: WARN TestLogger : this is your last warning\n",
- stderr[0].gets)
+ if defined?(::Syslog::LOG_PERROR)
+ assert_equal("syslog_test: INFO TestLogger : <Array> #{[1,2,3,4]}\n",
+ stderr[0].gets)
+ assert_equal("syslog_test: DEBUG TestLogger : the big log message\n",
+ stderr[0].gets)
+ assert_equal("syslog_test: WARN TestLogger : this is your last warning\n",
+ stderr[0].gets)
+ end
end
def test_append_error
@@ -98,9 +100,11 @@ def test_concat
stderr[1].close
Process.waitpid(pid)
- assert_equal("syslog_test: this is a test message\n", stderr[0].gets)
- assert_equal("syslog_test: this is another message\n", stderr[0].gets)
- assert_equal("syslog_test: some other line\n", stderr[0].gets)
+ if defined?(::Syslog::LOG_PERROR)
+ assert_equal("syslog_test: this is a test message\n", stderr[0].gets)
+ assert_equal("syslog_test: this is another message\n", stderr[0].gets)
+ assert_equal("syslog_test: some other line\n", stderr[0].gets)
+ end
end
def test_concat_error