6 require Config; import Config;
7 if ($Config{'extensions'} !~ /\bSyslog\b/) {
8 print "1..0 # Skip: Sys::Syslog was not built\n";
11 if ($Config{'extensions'} !~ /\bSocket\b/) {
12 print "1..0 # Skip: Socket was not built\n";
16 # This code inspired by Sys::Syslog::connect():
17 require Sys::Hostname;
18 my ($host_uniq) = Sys::Hostname::hostname();
19 my ($host) = $host_uniq =~ /([A-Za-z0-9_.-]+)/;
21 if (! defined Socket::inet_aton($host)) {
22 print "1..0 # Skip: Can't lookup $host\n";
28 eval {require Sys::Syslog} or do {
29 if ($@ =~ /Your vendor has not/) {
30 print "1..0 # Skip: missing macros\n";
36 use Sys::Syslog qw(:DEFAULT setlogsock);
38 # Test this to 1 if your syslog accepts udp connections.
39 # Most don't (or at least shouldn't)
40 my $Test_Syslog_INET = 0;
42 my $test_string = "uid $< is testing perl $] syslog capabilities";
46 if (Sys::Syslog::_PATH_LOG()) {
47 if (-e Sys::Syslog::_PATH_LOG()) {
48 print defined(eval { setlogsock('unix') }) ? "ok 1\n" : "not ok 1 # $!\n";
49 print defined(eval { openlog('perl', 'ndelay', 'local0') }) ? "ok 2\n" : "not ok 2 # $!\n";
50 print defined(eval { syslog('info', $test_string ) }) ? "ok 3\n" : "not ok 3 # $!\n";
55 "ok $_ # Skip: file ",
56 Sys::Syslog::_PATH_LOG(),
62 for (1..3) { print "ok $_ # Skip: _PATH_LOG unavailable\n" }
65 if( $Test_Syslog_INET ) {
66 print defined(eval { setlogsock('inet') }) ? "ok 4\n"
68 print defined(eval { openlog('perl', 'ndelay', 'local0') }) ? "ok 5\n"
70 print defined(eval { syslog('info', $test_string ) }) ? "ok 6\n"
74 print "ok $_ # Skip: assuming syslog doesn't accept inet connections\n"