6 require Config; import Config;
7 if ($Config{'extensions'} !~ /\bSyslog\b/) {
8 print "1..0 # Skip: Sys::Syslog was not built\n";
14 # This code inspired by Sys::Syslog::connect():
15 require Sys::Hostname;
16 my ($host_uniq) = Sys::Hostname::hostname();
17 my ($host) = $host_uniq =~ /([A-Za-z0-9_.-]+)/;
19 if (! defined Socket::inet_aton($host)) {
20 print "1..0 # Skip: Can't lookup $host\n";
26 eval {require Sys::Syslog} or do {
27 if ($@ =~ /Your vendor has not/) {
28 print "1..0 # Skipped: missing macros\n";
34 use Sys::Syslog qw(:DEFAULT setlogsock);
36 # Test this to 1 if your syslog accepts udp connections.
37 # Most don't (or at least shouldn't)
38 my $Test_Syslog_INET = 0;
42 if (Sys::Syslog::_PATH_LOG()) {
43 if (-e Sys::Syslog::_PATH_LOG()) {
44 print defined(eval { setlogsock('unix') }) ? "ok 1\n" : "not ok 1\n";
45 print defined(eval { openlog('perl', 'ndelay', 'local0') }) ? "ok 2\n" : "not ok 2\n";
46 print defined(eval { syslog('info', 'test') }) ? "ok 3\n" : "not ok 3\n";
51 "ok $_ # skipping, file ",
52 Sys::Syslog::_PATH_LOG(),
58 for (1..3) { print "ok $_ # skipping, _PATH_LOG unavailable\n" }
61 if( $Test_Syslog_INET ) {
62 print defined(eval { setlogsock('inet') }) ? "ok 4\n"
64 print defined(eval { openlog('perl', 'ndelay', 'local0') }) ? "ok 5\n"
66 print defined(eval { syslog('info', 'test') }) ? "ok 6\n"
70 print "ok $_ # skipped(assuming syslog doesn't accept inet connections)\n"