1package Sys::Syslog; 2use strict; 3use warnings; 4use warnings::register; 5use Carp; 6use Exporter (); 7use Fcntl qw(O_WRONLY); 8use File::Basename; 9use POSIX qw(strftime setlocale LC_TIME); 10use Socket ':all'; 11require 5.005; 12 13{ no strict 'vars'; 14 $VERSION = '0.27'; 15 @ISA = qw(Exporter); 16 17 %EXPORT_TAGS = ( 18 standard => [qw(openlog syslog closelog setlogmask)], 19 extended => [qw(setlogsock)], 20 macros => [ 21 # levels 22 qw( 23 LOG_ALERT LOG_CRIT LOG_DEBUG LOG_EMERG LOG_ERR 24 LOG_INFO LOG_NOTICE LOG_WARNING 25 ), 26 27 # standard facilities 28 qw( 29 LOG_AUTH LOG_AUTHPRIV LOG_CRON LOG_DAEMON LOG_FTP LOG_KERN 30 LOG_LOCAL0 LOG_LOCAL1 LOG_LOCAL2 LOG_LOCAL3 LOG_LOCAL4 31 LOG_LOCAL5 LOG_LOCAL6 LOG_LOCAL7 LOG_LPR LOG_MAIL LOG_NEWS 32 LOG_SYSLOG LOG_USER LOG_UUCP 33 ), 34 # Mac OS X specific facilities 35 qw( LOG_INSTALL LOG_LAUNCHD LOG_NETINFO LOG_RAS LOG_REMOTEAUTH ), 36 # modern BSD specific facilities 37 qw( LOG_CONSOLE LOG_NTP LOG_SECURITY ), 38 # IRIX specific facilities 39 qw( LOG_AUDIT LOG_LFMT ), 40 41 # options 42 qw( 43 LOG_CONS LOG_PID LOG_NDELAY LOG_NOWAIT LOG_ODELAY LOG_PERROR 44 ), 45 46 # others macros 47 qw( 48 LOG_FACMASK LOG_NFACILITIES LOG_PRIMASK 49 LOG_MASK LOG_UPTO 50 ), 51 ], 52 ); 53 54 @EXPORT = ( 55 @{$EXPORT_TAGS{standard}}, 56 ); 57 58 @EXPORT_OK = ( 59 @{$EXPORT_TAGS{extended}}, 60 @{$EXPORT_TAGS{macros}}, 61 ); 62 63 eval { 64 require XSLoader; 65 XSLoader::load('Sys::Syslog', $VERSION); 66 1 67 } or do { 68 require DynaLoader; 69 push @ISA, 'DynaLoader'; 70 bootstrap Sys::Syslog $VERSION; 71 }; 72} 73 74 75# 76# Public variables 77# 78use vars qw($host); # host to send syslog messages to (see notes at end) 79 80# 81# Prototypes 82# 83sub silent_eval (&); 84 85# 86# Global variables 87# 88use vars qw($facility); 89my $connected = 0; # flag to indicate if we're connected or not 90my $syslog_send; # coderef of the function used to send messages 91my $syslog_path = undef; # syslog path for "stream" and "unix" mechanisms 92my $syslog_xobj = undef; # if defined, holds the external object used to send messages 93my $transmit_ok = 0; # flag to indicate if the last message was transmited 94my $sock_timeout = 0; # socket timeout, see below 95my $current_proto = undef; # current mechanism used to transmit messages 96my $ident = ''; # identifiant prepended to each message 97$facility = ''; # current facility 98my $maskpri = LOG_UPTO(&LOG_DEBUG); # current log mask 99 100my %options = ( 101 ndelay => 0, 102 nofatal => 0, 103 nowait => 0, 104 perror => 0, 105 pid => 0, 106); 107 108# Default is now to first use the native mechanism, so Perl programs 109# behave like other normal Unix programs, then try other mechanisms. 110my @connectMethods = qw(native tcp udp unix pipe stream console); 111if ($^O =~ /^(freebsd|linux)$/) { 112 @connectMethods = grep { $_ ne 'udp' } @connectMethods; 113} 114 115# And on Win32 systems, we try to use the native mechanism for this 116# platform, the events logger, available through Win32::EventLog. 117EVENTLOG: { 118 my $is_Win32 = $^O =~ /Win32/i; 119 120 if (can_load("Sys::Syslog::Win32")) { 121 unshift @connectMethods, 'eventlog'; 122 } 123 elsif ($is_Win32) { 124 warn $@; 125 } 126} 127 128my @defaultMethods = @connectMethods; 129my @fallbackMethods = (); 130 131# The timeout in connection_ok() was pushed up to 0.25 sec in 132# Sys::Syslog v0.19 in order to address a heisenbug on MacOSX: 133# http://london.pm.org/pipermail/london.pm/Week-of-Mon-20061211/005961.html 134# 135# However, this also had the effect of slowing this test for 136# all other operating systems, which apparently impacted some 137# users (cf. CPAN-RT #34753). So, in order to make everybody 138# happy, the timeout is now zero by default on all systems 139# except on OSX where it is set to 250 msec, and can be set 140# with the infamous setlogsock() function. 141$sock_timeout = 0.25 if $^O =~ /darwin/; 142 143# coderef for a nicer handling of errors 144my $err_sub = $options{nofatal} ? \&warnings::warnif : \&croak; 145 146 147sub AUTOLOAD { 148 # This AUTOLOAD is used to 'autoload' constants from the constant() 149 # XS function. 150 no strict 'vars'; 151 my $constname; 152 ($constname = $AUTOLOAD) =~ s/.*:://; 153 croak "Sys::Syslog::constant() not defined" if $constname eq 'constant'; 154 my ($error, $val) = constant($constname); 155 croak $error if $error; 156 no strict 'refs'; 157 *$AUTOLOAD = sub { $val }; 158 goto &$AUTOLOAD; 159} 160 161 162sub openlog { 163 ($ident, my $logopt, $facility) = @_; 164 165 # default values 166 $ident ||= basename($0) || getlogin() || getpwuid($<) || 'syslog'; 167 $logopt ||= ''; 168 $facility ||= LOG_USER(); 169 170 for my $opt (split /\b/, $logopt) { 171 $options{$opt} = 1 if exists $options{$opt} 172 } 173 174 $err_sub = delete $options{nofatal} ? \&warnings::warnif : \&croak; 175 return 1 unless $options{ndelay}; 176 connect_log(); 177} 178 179sub closelog { 180 $facility = $ident = ''; 181 disconnect_log(); 182} 183 184sub setlogmask { 185 my $oldmask = $maskpri; 186 $maskpri = shift unless $_[0] == 0; 187 $oldmask; 188} 189 190sub setlogsock { 191 my ($setsock, $setpath, $settime) = @_; 192 193 # check arguments 194 my $diag_invalid_arg 195 = "Invalid argument passed to setlogsock; must be 'stream', 'pipe', " 196 . "'unix', 'native', 'eventlog', 'tcp', 'udp' or 'inet'"; 197 croak $diag_invalid_arg unless defined $setsock; 198 croak "Invalid number of arguments" unless @_ >= 1 and @_ <= 3; 199 200 $syslog_path = $setpath if defined $setpath; 201 $sock_timeout = $settime if defined $settime; 202 203 disconnect_log() if $connected; 204 $transmit_ok = 0; 205 @fallbackMethods = (); 206 @connectMethods = @defaultMethods; 207 208 if (ref $setsock eq 'ARRAY') { 209 @connectMethods = @$setsock; 210 211 } elsif (lc $setsock eq 'stream') { 212 if (not defined $syslog_path) { 213 my @try = qw(/dev/log /dev/conslog); 214 215 if (length &_PATH_LOG) { # Undefined _PATH_LOG is "". 216 unshift @try, &_PATH_LOG; 217 } 218 219 for my $try (@try) { 220 if (-w $try) { 221 $syslog_path = $try; 222 last; 223 } 224 } 225 226 if (not defined $syslog_path) { 227 warnings::warnif "stream passed to setlogsock, but could not find any device"; 228 return undef 229 } 230 } 231 232 if (not -w $syslog_path) { 233 warnings::warnif "stream passed to setlogsock, but $syslog_path is not writable"; 234 return undef; 235 } else { 236 @connectMethods = qw(stream); 237 } 238 239 } elsif (lc $setsock eq 'unix') { 240 if (length _PATH_LOG() || (defined $syslog_path && -w $syslog_path)) { 241 $syslog_path = _PATH_LOG() unless defined $syslog_path; 242 @connectMethods = qw(unix); 243 } else { 244 warnings::warnif 'unix passed to setlogsock, but path not available'; 245 return undef; 246 } 247 248 } elsif (lc $setsock eq 'pipe') { 249 for my $path ($syslog_path, &_PATH_LOG, "/dev/log") { 250 next unless defined $path and length $path and -p $path and -w _; 251 $syslog_path = $path; 252 last 253 } 254 255 if (not $syslog_path) { 256 warnings::warnif "pipe passed to setlogsock, but path not available"; 257 return undef 258 } 259 260 @connectMethods = qw(pipe); 261 262 } elsif (lc $setsock eq 'native') { 263 @connectMethods = qw(native); 264 265 } elsif (lc $setsock eq 'eventlog') { 266 if (can_load("Win32::EventLog")) { 267 @connectMethods = qw(eventlog); 268 } else { 269 warnings::warnif "eventlog passed to setlogsock, but no Win32 API available"; 270 $@ = ""; 271 return undef; 272 } 273 274 } elsif (lc $setsock eq 'tcp') { 275 if (getservbyname('syslog', 'tcp') || getservbyname('syslogng', 'tcp')) { 276 @connectMethods = qw(tcp); 277 $host = $syslog_path; 278 } else { 279 warnings::warnif "tcp passed to setlogsock, but tcp service unavailable"; 280 return undef; 281 } 282 283 } elsif (lc $setsock eq 'udp') { 284 if (getservbyname('syslog', 'udp')) { 285 @connectMethods = qw(udp); 286 $host = $syslog_path; 287 } else { 288 warnings::warnif "udp passed to setlogsock, but udp service unavailable"; 289 return undef; 290 } 291 292 } elsif (lc $setsock eq 'inet') { 293 @connectMethods = ( 'tcp', 'udp' ); 294 295 } elsif (lc $setsock eq 'console') { 296 @connectMethods = qw(console); 297 298 } else { 299 croak $diag_invalid_arg 300 } 301 302 return 1; 303} 304 305sub syslog { 306 my $priority = shift; 307 my $mask = shift; 308 my ($message, $buf); 309 my (@words, $num, $numpri, $numfac, $sum); 310 my $failed = undef; 311 my $fail_time = undef; 312 my $error = $!; 313 314 # if $ident is undefined, it means openlog() wasn't previously called 315 # so do it now in order to have sensible defaults 316 openlog() unless $ident; 317 318 local $facility = $facility; # may need to change temporarily. 319 320 croak "syslog: expecting argument \$priority" unless defined $priority; 321 croak "syslog: expecting argument \$format" unless defined $mask; 322 323 croak "syslog: invalid level/facility: $priority" if $priority =~ /^-\d+$/; 324 @words = split(/\W+/, $priority, 2); # Allow "level" or "level|facility". 325 undef $numpri; 326 undef $numfac; 327 328 for my $word (@words) { 329 next if length $word == 0; 330 331 $num = xlate($word); # Translate word to number. 332 333 if ($num < 0) { 334 croak "syslog: invalid level/facility: $word" 335 } 336 elsif ($num <= &LOG_PRIMASK) { 337 croak "syslog: too many levels given: $word" if defined $numpri; 338 $numpri = $num; 339 return 0 unless LOG_MASK($numpri) & $maskpri; 340 } 341 else { 342 croak "syslog: too many facilities given: $word" if defined $numfac; 343 $facility = $word; 344 $numfac = $num; 345 } 346 } 347 348 croak "syslog: level must be given" unless defined $numpri; 349 350 if (not defined $numfac) { # Facility not specified in this call. 351 $facility = 'user' unless $facility; 352 $numfac = xlate($facility); 353 } 354 355 connect_log() unless $connected; 356 357 if ($mask =~ /%m/) { 358 # escape percent signs for sprintf() 359 $error =~ s/%/%%/g if @_; 360 # replace %m with $error, if preceded by an even number of percent signs 361 $mask =~ s/(?<!%)((?:%%)*)%m/$1$error/g; 362 } 363 364 $mask .= "\n" unless $mask =~ /\n$/; 365 $message = @_ ? sprintf($mask, @_) : $mask; 366 367 # See CPAN-RT#24431. Opened on Apple Radar as bug #4944407 on 2007.01.21 368 # Supposedly resolved on Leopard. 369 chomp $message if $^O =~ /darwin/; 370 371 if ($current_proto eq 'native') { 372 $buf = $message; 373 } 374 elsif ($current_proto eq 'eventlog') { 375 $buf = $message; 376 } 377 else { 378 my $whoami = $ident; 379 $whoami .= "[$$]" if $options{pid}; 380 381 $sum = $numpri + $numfac; 382 my $oldlocale = setlocale(LC_TIME); 383 setlocale(LC_TIME, 'C'); 384 my $timestamp = strftime "%b %e %T", localtime; 385 setlocale(LC_TIME, $oldlocale); 386 $buf = "<$sum>$timestamp $whoami: $message\0"; 387 } 388 389 # handle PERROR option 390 # "native" mechanism already handles it by itself 391 if ($options{perror} and $current_proto ne 'native') { 392 chomp $message; 393 my $whoami = $ident; 394 $whoami .= "[$$]" if $options{pid}; 395 print STDERR "$whoami: $message\n"; 396 } 397 398 # it's possible that we'll get an error from sending 399 # (e.g. if method is UDP and there is no UDP listener, 400 # then we'll get ECONNREFUSED on the send). So what we 401 # want to do at this point is to fallback onto a different 402 # connection method. 403 while (scalar @fallbackMethods || $syslog_send) { 404 if ($failed && (time - $fail_time) > 60) { 405 # it's been a while... maybe things have been fixed 406 @fallbackMethods = (); 407 disconnect_log(); 408 $transmit_ok = 0; # make it look like a fresh attempt 409 connect_log(); 410 } 411 412 if ($connected && !connection_ok()) { 413 # Something was OK, but has now broken. Remember coz we'll 414 # want to go back to what used to be OK. 415 $failed = $current_proto unless $failed; 416 $fail_time = time; 417 disconnect_log(); 418 } 419 420 connect_log() unless $connected; 421 $failed = undef if ($current_proto && $failed && $current_proto eq $failed); 422 423 if ($syslog_send) { 424 if ($syslog_send->($buf, $numpri, $numfac)) { 425 $transmit_ok++; 426 return 1; 427 } 428 # typically doesn't happen, since errors are rare from write(). 429 disconnect_log(); 430 } 431 } 432 # could not send, could not fallback onto a working 433 # connection method. Lose. 434 return 0; 435} 436 437sub _syslog_send_console { 438 my ($buf) = @_; 439 chop($buf); # delete the NUL from the end 440 # The console print is a method which could block 441 # so we do it in a child process and always return success 442 # to the caller. 443 if (my $pid = fork) { 444 445 if ($options{nowait}) { 446 return 1; 447 } else { 448 if (waitpid($pid, 0) >= 0) { 449 return ($? >> 8); 450 } else { 451 # it's possible that the caller has other 452 # plans for SIGCHLD, so let's not interfere 453 return 1; 454 } 455 } 456 } else { 457 if (open(CONS, ">/dev/console")) { 458 my $ret = print CONS $buf . "\r"; # XXX: should this be \x0A ? 459 exit $ret if defined $pid; 460 close CONS; 461 } 462 exit if defined $pid; 463 } 464} 465 466sub _syslog_send_stream { 467 my ($buf) = @_; 468 # XXX: this only works if the OS stream implementation makes a write 469 # look like a putmsg() with simple header. For instance it works on 470 # Solaris 8 but not Solaris 7. 471 # To be correct, it should use a STREAMS API, but perl doesn't have one. 472 return syswrite(SYSLOG, $buf, length($buf)); 473} 474 475sub _syslog_send_pipe { 476 my ($buf) = @_; 477 return print SYSLOG $buf; 478} 479 480sub _syslog_send_socket { 481 my ($buf) = @_; 482 return syswrite(SYSLOG, $buf, length($buf)); 483 #return send(SYSLOG, $buf, 0); 484} 485 486sub _syslog_send_native { 487 my ($buf, $numpri) = @_; 488 syslog_xs($numpri, $buf); 489 return 1; 490} 491 492 493# xlate() 494# ----- 495# private function to translate names to numeric values 496# 497sub xlate { 498 my ($name) = @_; 499 500 return $name+0 if $name =~ /^\s*\d+\s*$/; 501 $name = uc $name; 502 $name = "LOG_$name" unless $name =~ /^LOG_/; 503 504 # ExtUtils::Constant 0.20 introduced a new way to implement 505 # constants, called ProxySubs. When it was used to generate 506 # the C code, the constant() function no longer returns the 507 # correct value. Therefore, we first try a direct call to 508 # constant(), and if the value is an error we try to call the 509 # constant by its full name. 510 my $value = constant($name); 511 512 if (index($value, "not a valid") >= 0) { 513 $name = "Sys::Syslog::$name"; 514 $value = eval { no strict "refs"; &$name }; 515 $value = $@ unless defined $value; 516 } 517 518 $value = -1 if index($value, "not a valid") >= 0; 519 520 return defined $value ? $value : -1; 521} 522 523 524# connect_log() 525# ----------- 526# This function acts as a kind of front-end: it tries to connect to 527# a syslog service using the selected methods, trying each one in the 528# selected order. 529# 530sub connect_log { 531 @fallbackMethods = @connectMethods unless scalar @fallbackMethods; 532 533 if ($transmit_ok && $current_proto) { 534 # Retry what we were on, because it has worked in the past. 535 unshift(@fallbackMethods, $current_proto); 536 } 537 538 $connected = 0; 539 my @errs = (); 540 my $proto = undef; 541 542 while ($proto = shift @fallbackMethods) { 543 no strict 'refs'; 544 my $fn = "connect_$proto"; 545 $connected = &$fn(\@errs) if defined &$fn; 546 last if $connected; 547 } 548 549 $transmit_ok = 0; 550 if ($connected) { 551 $current_proto = $proto; 552 my ($old) = select(SYSLOG); $| = 1; select($old); 553 } else { 554 @fallbackMethods = (); 555 $err_sub->(join "\n\t- ", "no connection to syslog available", @errs); 556 return undef; 557 } 558} 559 560sub connect_tcp { 561 my ($errs) = @_; 562 563 my $tcp = getprotobyname('tcp'); 564 if (!defined $tcp) { 565 push @$errs, "getprotobyname failed for tcp"; 566 return 0; 567 } 568 569 my $syslog = getservbyname('syslog', 'tcp'); 570 $syslog = getservbyname('syslogng', 'tcp') unless defined $syslog; 571 if (!defined $syslog) { 572 push @$errs, "getservbyname failed for syslog/tcp and syslogng/tcp"; 573 return 0; 574 } 575 576 my $addr; 577 if (defined $host) { 578 $addr = inet_aton($host); 579 if (!$addr) { 580 push @$errs, "can't lookup $host"; 581 return 0; 582 } 583 } else { 584 $addr = INADDR_LOOPBACK; 585 } 586 $addr = sockaddr_in($syslog, $addr); 587 588 if (!socket(SYSLOG, AF_INET, SOCK_STREAM, $tcp)) { 589 push @$errs, "tcp socket: $!"; 590 return 0; 591 } 592 593 setsockopt(SYSLOG, SOL_SOCKET, SO_KEEPALIVE, 1); 594 if (silent_eval { IPPROTO_TCP() }) { 595 # These constants don't exist in 5.005. They were added in 1999 596 setsockopt(SYSLOG, IPPROTO_TCP(), TCP_NODELAY(), 1); 597 } 598 if (!connect(SYSLOG, $addr)) { 599 push @$errs, "tcp connect: $!"; 600 return 0; 601 } 602 603 $syslog_send = \&_syslog_send_socket; 604 605 return 1; 606} 607 608sub connect_udp { 609 my ($errs) = @_; 610 611 my $udp = getprotobyname('udp'); 612 if (!defined $udp) { 613 push @$errs, "getprotobyname failed for udp"; 614 return 0; 615 } 616 617 my $syslog = getservbyname('syslog', 'udp'); 618 if (!defined $syslog) { 619 push @$errs, "getservbyname failed for syslog/udp"; 620 return 0; 621 } 622 623 my $addr; 624 if (defined $host) { 625 $addr = inet_aton($host); 626 if (!$addr) { 627 push @$errs, "can't lookup $host"; 628 return 0; 629 } 630 } else { 631 $addr = INADDR_LOOPBACK; 632 } 633 $addr = sockaddr_in($syslog, $addr); 634 635 if (!socket(SYSLOG, AF_INET, SOCK_DGRAM, $udp)) { 636 push @$errs, "udp socket: $!"; 637 return 0; 638 } 639 if (!connect(SYSLOG, $addr)) { 640 push @$errs, "udp connect: $!"; 641 return 0; 642 } 643 644 # We want to check that the UDP connect worked. However the only 645 # way to do that is to send a message and see if an ICMP is returned 646 _syslog_send_socket(""); 647 if (!connection_ok()) { 648 push @$errs, "udp connect: nobody listening"; 649 return 0; 650 } 651 652 $syslog_send = \&_syslog_send_socket; 653 654 return 1; 655} 656 657sub connect_stream { 658 my ($errs) = @_; 659 # might want syslog_path to be variable based on syslog.h (if only 660 # it were in there!) 661 $syslog_path = '/dev/conslog' unless defined $syslog_path; 662 if (!-w $syslog_path) { 663 push @$errs, "stream $syslog_path is not writable"; 664 return 0; 665 } 666 if (!sysopen(SYSLOG, $syslog_path, O_WRONLY, 0400)) { 667 push @$errs, "stream can't open $syslog_path: $!"; 668 return 0; 669 } 670 $syslog_send = \&_syslog_send_stream; 671 return 1; 672} 673 674sub connect_pipe { 675 my ($errs) = @_; 676 677 $syslog_path ||= &_PATH_LOG || "/dev/log"; 678 679 if (not -w $syslog_path) { 680 push @$errs, "$syslog_path is not writable"; 681 return 0; 682 } 683 684 if (not open(SYSLOG, ">$syslog_path")) { 685 push @$errs, "can't write to $syslog_path: $!"; 686 return 0; 687 } 688 689 $syslog_send = \&_syslog_send_pipe; 690 691 return 1; 692} 693 694sub connect_unix { 695 my ($errs) = @_; 696 697 $syslog_path ||= _PATH_LOG() if length _PATH_LOG(); 698 699 if (not defined $syslog_path) { 700 push @$errs, "_PATH_LOG not available in syslog.h and no user-supplied socket path"; 701 return 0; 702 } 703 704 if (not (-S $syslog_path or -c _)) { 705 push @$errs, "$syslog_path is not a socket"; 706 return 0; 707 } 708 709 my $addr = sockaddr_un($syslog_path); 710 if (!$addr) { 711 push @$errs, "can't locate $syslog_path"; 712 return 0; 713 } 714 if (!socket(SYSLOG, AF_UNIX, SOCK_STREAM, 0)) { 715 push @$errs, "unix stream socket: $!"; 716 return 0; 717 } 718 719 if (!connect(SYSLOG, $addr)) { 720 if (!socket(SYSLOG, AF_UNIX, SOCK_DGRAM, 0)) { 721 push @$errs, "unix dgram socket: $!"; 722 return 0; 723 } 724 if (!connect(SYSLOG, $addr)) { 725 push @$errs, "unix dgram connect: $!"; 726 return 0; 727 } 728 } 729 730 $syslog_send = \&_syslog_send_socket; 731 732 return 1; 733} 734 735sub connect_native { 736 my ($errs) = @_; 737 my $logopt = 0; 738 739 # reconstruct the numeric equivalent of the options 740 for my $opt (keys %options) { 741 $logopt += xlate($opt) if $options{$opt} 742 } 743 744 openlog_xs($ident, $logopt, xlate($facility)); 745 $syslog_send = \&_syslog_send_native; 746 747 return 1; 748} 749 750sub connect_eventlog { 751 my ($errs) = @_; 752 753 $syslog_xobj = Sys::Syslog::Win32::_install(); 754 $syslog_send = \&Sys::Syslog::Win32::_syslog_send; 755 756 return 1; 757} 758 759sub connect_console { 760 my ($errs) = @_; 761 if (!-w '/dev/console') { 762 push @$errs, "console is not writable"; 763 return 0; 764 } 765 $syslog_send = \&_syslog_send_console; 766 return 1; 767} 768 769# To test if the connection is still good, we need to check if any 770# errors are present on the connection. The errors will not be raised 771# by a write. Instead, sockets are made readable and the next read 772# would cause the error to be returned. Unfortunately the syslog 773# 'protocol' never provides anything for us to read. But with 774# judicious use of select(), we can see if it would be readable... 775sub connection_ok { 776 return 1 if defined $current_proto and ( 777 $current_proto eq 'native' or $current_proto eq 'console' 778 or $current_proto eq 'eventlog' 779 ); 780 781 my $rin = ''; 782 vec($rin, fileno(SYSLOG), 1) = 1; 783 my $ret = select $rin, undef, $rin, $sock_timeout; 784 return ($ret ? 0 : 1); 785} 786 787sub disconnect_log { 788 $connected = 0; 789 $syslog_send = undef; 790 791 if (defined $current_proto and $current_proto eq 'native') { 792 closelog_xs(); 793 return 1; 794 } 795 elsif (defined $current_proto and $current_proto eq 'eventlog') { 796 $syslog_xobj->Close(); 797 return 1; 798 } 799 800 return close SYSLOG; 801} 802 803 804# 805# Wrappers around eval() that makes sure that nobody, and I say NOBODY, 806# ever knows that I wanted to test if something was here or not. 807# It is needed because some applications are trying to be too smart, 808# do it wrong, and it ends up in EPIC FAIL. 809# Yes I'm speaking of YOU, SpamAssassin. 810# 811sub silent_eval (&) { 812 local($SIG{__DIE__}, $SIG{__WARN__}, $@); 813 return eval { $_[0]->() } 814} 815 816sub can_load { 817 local($SIG{__DIE__}, $SIG{__WARN__}, $@); 818 return eval "use $_[0]; 1" 819} 820 821 822"Eighth Rule: read the documentation." 823 824__END__ 825 826=head1 NAME 827 828Sys::Syslog - Perl interface to the UNIX syslog(3) calls 829 830=head1 VERSION 831 832Version 0.27 833 834=head1 SYNOPSIS 835 836 use Sys::Syslog; # all except setlogsock(), or: 837 use Sys::Syslog qw(:DEFAULT setlogsock); # default set, plus setlogsock() 838 use Sys::Syslog qw(:standard :macros); # standard functions, plus macros 839 840 openlog $ident, $logopt, $facility; # don't forget this 841 syslog $priority, $format, @args; 842 $oldmask = setlogmask $mask_priority; 843 closelog; 844 845 846=head1 DESCRIPTION 847 848C<Sys::Syslog> is an interface to the UNIX C<syslog(3)> program. 849Call C<syslog()> with a string priority and a list of C<printf()> args 850just like C<syslog(3)>. 851 852You can find a kind of FAQ in L<"THE RULES OF SYS::SYSLOG">. Please read 853it before coding, and again before asking questions. 854 855 856=head1 EXPORTS 857 858C<Sys::Syslog> exports the following C<Exporter> tags: 859 860=over 4 861 862=item * 863 864C<:standard> exports the standard C<syslog(3)> functions: 865 866 openlog closelog setlogmask syslog 867 868=item * 869 870C<:extended> exports the Perl specific functions for C<syslog(3)>: 871 872 setlogsock 873 874=item * 875 876C<:macros> exports the symbols corresponding to most of your C<syslog(3)> 877macros and the C<LOG_UPTO()> and C<LOG_MASK()> functions. 878See L<"CONSTANTS"> for the supported constants and their meaning. 879 880=back 881 882By default, C<Sys::Syslog> exports the symbols from the C<:standard> tag. 883 884 885=head1 FUNCTIONS 886 887=over 4 888 889=item B<openlog($ident, $logopt, $facility)> 890 891Opens the syslog. 892C<$ident> is prepended to every message. C<$logopt> contains zero or 893more of the options detailed below. C<$facility> specifies the part 894of the system to report about, for example C<LOG_USER> or C<LOG_LOCAL0>: 895see L<"Facilities"> for a list of well-known facilities, and your 896C<syslog(3)> documentation for the facilities available in your system. 897Check L<"SEE ALSO"> for useful links. Facility can be given as a string 898or a numeric macro. 899 900This function will croak if it can't connect to the syslog daemon. 901 902Note that C<openlog()> now takes three arguments, just like C<openlog(3)>. 903 904B<You should use C<openlog()> before calling C<syslog()>.> 905 906B<Options> 907 908=over 4 909 910=item * 911 912C<cons> - This option is ignored, since the failover mechanism will drop 913down to the console automatically if all other media fail. 914 915=item * 916 917C<ndelay> - Open the connection immediately (normally, the connection is 918opened when the first message is logged). 919 920=item * 921 922C<nofatal> - When set to true, C<openlog()> and C<syslog()> will only 923emit warnings instead of dying if the connection to the syslog can't 924be established. 925 926=item * 927 928C<nowait> - Don't wait for child processes that may have been created 929while logging the message. (The GNU C library does not create a child 930process, so this option has no effect on Linux.) 931 932=item * 933 934C<perror> - Write the message to standard error output as well to the 935system log. 936 937=item * 938 939C<pid> - Include PID with each message. 940 941=back 942 943B<Examples> 944 945Open the syslog with options C<ndelay> and C<pid>, and with facility C<LOCAL0>: 946 947 openlog($name, "ndelay,pid", "local0"); 948 949Same thing, but this time using the macro corresponding to C<LOCAL0>: 950 951 openlog($name, "ndelay,pid", LOG_LOCAL0); 952 953 954=item B<syslog($priority, $message)> 955 956=item B<syslog($priority, $format, @args)> 957 958If C<$priority> permits, logs C<$message> or C<sprintf($format, @args)> 959with the addition that C<%m> in $message or C<$format> is replaced with 960C<"$!"> (the latest error message). 961 962C<$priority> can specify a level, or a level and a facility. Levels and 963facilities can be given as strings or as macros. When using the C<eventlog> 964mechanism, priorities C<DEBUG> and C<INFO> are mapped to event type 965C<informational>, C<NOTICE> and C<WARNIN> to C<warning> and C<ERR> to 966C<EMERG> to C<error>. 967 968If you didn't use C<openlog()> before using C<syslog()>, C<syslog()> will 969try to guess the C<$ident> by extracting the shortest prefix of 970C<$format> that ends in a C<":">. 971 972B<Examples> 973 974 syslog("info", $message); # informational level 975 syslog(LOG_INFO, $message); # informational level 976 977 syslog("info|local0", $message); # information level, Local0 facility 978 syslog(LOG_INFO|LOG_LOCAL0, $message); # information level, Local0 facility 979 980=over 4 981 982=item B<Note> 983 984C<Sys::Syslog> version v0.07 and older passed the C<$message> as the 985formatting string to C<sprintf()> even when no formatting arguments 986were provided. If the code calling C<syslog()> might execute with 987older versions of this module, make sure to call the function as 988C<syslog($priority, "%s", $message)> instead of C<syslog($priority, 989$message)>. This protects against hostile formatting sequences that 990might show up if $message contains tainted data. 991 992=back 993 994 995=item B<setlogmask($mask_priority)> 996 997Sets the log mask for the current process to C<$mask_priority> and 998returns the old mask. If the mask argument is 0, the current log mask 999is not modified. See L<"Levels"> for the list of available levels. 1000You can use the C<LOG_UPTO()> function to allow all levels up to a 1001given priority (but it only accept the numeric macros as arguments). 1002 1003B<Examples> 1004 1005Only log errors: 1006 1007 setlogmask( LOG_MASK(LOG_ERR) ); 1008 1009Log everything except informational messages: 1010 1011 setlogmask( ~(LOG_MASK(LOG_INFO)) ); 1012 1013Log critical messages, errors and warnings: 1014 1015 setlogmask( LOG_MASK(LOG_CRIT) | LOG_MASK(LOG_ERR) | LOG_MASK(LOG_WARNING) ); 1016 1017Log all messages up to debug: 1018 1019 setlogmask( LOG_UPTO(LOG_DEBUG) ); 1020 1021 1022=item B<setlogsock($sock_type)> 1023 1024=item B<setlogsock($sock_type, $stream_location)> (added in Perl 5.004_02) 1025 1026=item B<setlogsock($sock_type, $stream_location, $sock_timeout)> (added in 0.25) 1027 1028Sets the socket type to be used for the next call to 1029C<openlog()> or C<syslog()> and returns true on success, 1030C<undef> on failure. The available mechanisms are: 1031 1032=over 1033 1034=item * 1035 1036C<"native"> - use the native C functions from your C<syslog(3)> library 1037(added in C<Sys::Syslog> 0.15). 1038 1039=item * 1040 1041C<"eventlog"> - send messages to the Win32 events logger (Win32 only; 1042added in C<Sys::Syslog> 0.19). 1043 1044=item * 1045 1046C<"tcp"> - connect to a TCP socket, on the C<syslog/tcp> or C<syslogng/tcp> 1047service. If defined, the second parameter is used as a hostname to connect to. 1048 1049=item * 1050 1051C<"udp"> - connect to a UDP socket, on the C<syslog/udp> service. 1052If defined, the second parameter is used as a hostname to connect to, 1053and the third parameter as the timeout used to check for UDP response. 1054 1055=item * 1056 1057C<"inet"> - connect to an INET socket, either TCP or UDP, tried in that 1058order. If defined, the second parameter is used as a hostname to connect to. 1059 1060=item * 1061 1062C<"unix"> - connect to a UNIX domain socket (in some systems a character 1063special device). The name of that socket is the second parameter or, if 1064you omit the second parameter, the value returned by the C<_PATH_LOG> macro 1065(if your system defines it), or F</dev/log> or F</dev/conslog>, whatever is 1066writable. 1067 1068=item * 1069 1070C<"stream"> - connect to the stream indicated by the pathname provided as 1071the optional second parameter, or, if omitted, to F</dev/conslog>. 1072For example Solaris and IRIX system may prefer C<"stream"> instead of C<"unix">. 1073 1074=item * 1075 1076C<"pipe"> - connect to the named pipe indicated by the pathname provided as 1077the optional second parameter, or, if omitted, to the value returned by 1078the C<_PATH_LOG> macro (if your system defines it), or F</dev/log> 1079(added in C<Sys::Syslog> 0.21). 1080 1081=item * 1082 1083C<"console"> - send messages directly to the console, as for the C<"cons"> 1084option of C<openlog()>. 1085 1086=back 1087 1088A reference to an array can also be passed as the first parameter. 1089When this calling method is used, the array should contain a list of 1090mechanisms which are attempted in order. 1091 1092The default is to try C<native>, C<tcp>, C<udp>, C<unix>, C<pipe>, C<stream>, 1093C<console>. 1094Under systems with the Win32 API, C<eventlog> will be added as the first 1095mechanism to try if C<Win32::EventLog> is available. 1096 1097Giving an invalid value for C<$sock_type> will C<croak>. 1098 1099B<Examples> 1100 1101Select the UDP socket mechanism: 1102 1103 setlogsock("udp"); 1104 1105Select the native, UDP socket then UNIX domain socket mechanisms: 1106 1107 setlogsock(["native", "udp", "unix"]); 1108 1109=over 1110 1111=item B<Note> 1112 1113Now that the "native" mechanism is supported by C<Sys::Syslog> and selected 1114by default, the use of the C<setlogsock()> function is discouraged because 1115other mechanisms are less portable across operating systems. Authors of 1116modules and programs that use this function, especially its cargo-cult form 1117C<setlogsock("unix")>, are advised to remove any occurence of it unless they 1118specifically want to use a given mechanism (like TCP or UDP to connect to 1119a remote host). 1120 1121=back 1122 1123=item B<closelog()> 1124 1125Closes the log file and returns true on success. 1126 1127=back 1128 1129 1130=head1 THE RULES OF SYS::SYSLOG 1131 1132I<The First Rule of Sys::Syslog is:> 1133You do not call C<setlogsock>. 1134 1135I<The Second Rule of Sys::Syslog is:> 1136You B<do not> call C<setlogsock>. 1137 1138I<The Third Rule of Sys::Syslog is:> 1139The program crashes, C<die>s, calls C<closelog>, the log is over. 1140 1141I<The Fourth Rule of Sys::Syslog is:> 1142One facility, one priority. 1143 1144I<The Fifth Rule of Sys::Syslog is:> 1145One log at a time. 1146 1147I<The Sixth Rule of Sys::Syslog is:> 1148No C<syslog> before C<openlog>. 1149 1150I<The Seventh Rule of Sys::Syslog is:> 1151Logs will go on as long as they have to. 1152 1153I<The Eighth, and Final Rule of Sys::Syslog is:> 1154If this is your first use of Sys::Syslog, you must read the doc. 1155 1156 1157=head1 EXAMPLES 1158 1159An example: 1160 1161 openlog($program, 'cons,pid', 'user'); 1162 syslog('info', '%s', 'this is another test'); 1163 syslog('mail|warning', 'this is a better test: %d', time); 1164 closelog(); 1165 1166 syslog('debug', 'this is the last test'); 1167 1168Another example: 1169 1170 openlog("$program $$", 'ndelay', 'user'); 1171 syslog('notice', 'fooprogram: this is really done'); 1172 1173Example of use of C<%m>: 1174 1175 $! = 55; 1176 syslog('info', 'problem was %m'); # %m == $! in syslog(3) 1177 1178Log to UDP port on C<$remotehost> instead of logging locally: 1179 1180 setlogsock("udp", $remotehost); 1181 openlog($program, 'ndelay', 'user'); 1182 syslog('info', 'something happened over here'); 1183 1184 1185=head1 CONSTANTS 1186 1187=head2 Facilities 1188 1189=over 4 1190 1191=item * 1192 1193C<LOG_AUDIT> - audit daemon (IRIX); falls back to C<LOG_AUTH> 1194 1195=item * 1196 1197C<LOG_AUTH> - security/authorization messages 1198 1199=item * 1200 1201C<LOG_AUTHPRIV> - security/authorization messages (private) 1202 1203=item * 1204 1205C<LOG_CONSOLE> - C</dev/console> output (FreeBSD); falls back to C<LOG_USER> 1206 1207=item * 1208 1209C<LOG_CRON> - clock daemons (B<cron> and B<at>) 1210 1211=item * 1212 1213C<LOG_DAEMON> - system daemons without separate facility value 1214 1215=item * 1216 1217C<LOG_FTP> - FTP daemon 1218 1219=item * 1220 1221C<LOG_KERN> - kernel messages 1222 1223=item * 1224 1225C<LOG_INSTALL> - installer subsystem (Mac OS X); falls back to C<LOG_USER> 1226 1227=item * 1228 1229C<LOG_LAUNCHD> - launchd - general bootstrap daemon (Mac OS X); 1230falls back to C<LOG_DAEMON> 1231 1232=item * 1233 1234C<LOG_LFMT> - logalert facility; falls back to C<LOG_USER> 1235 1236=item * 1237 1238C<LOG_LOCAL0> through C<LOG_LOCAL7> - reserved for local use 1239 1240=item * 1241 1242C<LOG_LPR> - line printer subsystem 1243 1244=item * 1245 1246C<LOG_MAIL> - mail subsystem 1247 1248=item * 1249 1250C<LOG_NETINFO> - NetInfo subsystem (Mac OS X); falls back to C<LOG_DAEMON> 1251 1252=item * 1253 1254C<LOG_NEWS> - USENET news subsystem 1255 1256=item * 1257 1258C<LOG_NTP> - NTP subsystem (FreeBSD, NetBSD); falls back to C<LOG_DAEMON> 1259 1260=item * 1261 1262C<LOG_RAS> - Remote Access Service (VPN / PPP) (Mac OS X); 1263falls back to C<LOG_AUTH> 1264 1265=item * 1266 1267C<LOG_REMOTEAUTH> - remote authentication/authorization (Mac OS X); 1268falls back to C<LOG_AUTH> 1269 1270=item * 1271 1272C<LOG_SECURITY> - security subsystems (firewalling, etc.) (FreeBSD); 1273falls back to C<LOG_AUTH> 1274 1275=item * 1276 1277C<LOG_SYSLOG> - messages generated internally by B<syslogd> 1278 1279=item * 1280 1281C<LOG_USER> (default) - generic user-level messages 1282 1283=item * 1284 1285C<LOG_UUCP> - UUCP subsystem 1286 1287=back 1288 1289 1290=head2 Levels 1291 1292=over 4 1293 1294=item * 1295 1296C<LOG_EMERG> - system is unusable 1297 1298=item * 1299 1300C<LOG_ALERT> - action must be taken immediately 1301 1302=item * 1303 1304C<LOG_CRIT> - critical conditions 1305 1306=item * 1307 1308C<LOG_ERR> - error conditions 1309 1310=item * 1311 1312C<LOG_WARNING> - warning conditions 1313 1314=item * 1315 1316C<LOG_NOTICE> - normal, but significant, condition 1317 1318=item * 1319 1320C<LOG_INFO> - informational message 1321 1322=item * 1323 1324C<LOG_DEBUG> - debug-level message 1325 1326=back 1327 1328 1329=head1 DIAGNOSTICS 1330 1331=over 1332 1333=item C<Invalid argument passed to setlogsock> 1334 1335B<(F)> You gave C<setlogsock()> an invalid value for C<$sock_type>. 1336 1337=item C<eventlog passed to setlogsock, but no Win32 API available> 1338 1339B<(W)> You asked C<setlogsock()> to use the Win32 event logger but the 1340operating system running the program isn't Win32 or does not provides Win32 1341compatible facilities. 1342 1343=item C<no connection to syslog available> 1344 1345B<(F)> C<syslog()> failed to connect to the specified socket. 1346 1347=item C<stream passed to setlogsock, but %s is not writable> 1348 1349B<(W)> You asked C<setlogsock()> to use a stream socket, but the given 1350path is not writable. 1351 1352=item C<stream passed to setlogsock, but could not find any device> 1353 1354B<(W)> You asked C<setlogsock()> to use a stream socket, but didn't 1355provide a path, and C<Sys::Syslog> was unable to find an appropriate one. 1356 1357=item C<tcp passed to setlogsock, but tcp service unavailable> 1358 1359B<(W)> You asked C<setlogsock()> to use a TCP socket, but the service 1360is not available on the system. 1361 1362=item C<syslog: expecting argument %s> 1363 1364B<(F)> You forgot to give C<syslog()> the indicated argument. 1365 1366=item C<syslog: invalid level/facility: %s> 1367 1368B<(F)> You specified an invalid level or facility. 1369 1370=item C<syslog: too many levels given: %s> 1371 1372B<(F)> You specified too many levels. 1373 1374=item C<syslog: too many facilities given: %s> 1375 1376B<(F)> You specified too many facilities. 1377 1378=item C<syslog: level must be given> 1379 1380B<(F)> You forgot to specify a level. 1381 1382=item C<udp passed to setlogsock, but udp service unavailable> 1383 1384B<(W)> You asked C<setlogsock()> to use a UDP socket, but the service 1385is not available on the system. 1386 1387=item C<unix passed to setlogsock, but path not available> 1388 1389B<(W)> You asked C<setlogsock()> to use a UNIX socket, but C<Sys::Syslog> 1390was unable to find an appropriate an appropriate device. 1391 1392=back 1393 1394 1395=head1 SEE ALSO 1396 1397=head2 Manual Pages 1398 1399L<syslog(3)> 1400 1401SUSv3 issue 6, IEEE Std 1003.1, 2004 edition, 1402L<http://www.opengroup.org/onlinepubs/000095399/basedefs/syslog.h.html> 1403 1404GNU C Library documentation on syslog, 1405L<http://www.gnu.org/software/libc/manual/html_node/Syslog.html> 1406 1407Solaris 10 documentation on syslog, 1408L<http://docs.sun.com/app/docs/doc/816-5168/syslog-3c?a=view> 1409 1410Mac OS X documentation on syslog, 1411L<http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/syslog.3.html> 1412 1413IRIX 6.5 documentation on syslog, 1414L<http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=0650&db=man&fname=3c+syslog> 1415 1416AIX 5L 5.3 documentation on syslog, 1417L<http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf2/syslog.htm> 1418 1419HP-UX 11i documentation on syslog, 1420L<http://docs.hp.com/en/B2355-60130/syslog.3C.html> 1421 1422Tru64 5.1 documentation on syslog, 1423L<http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51_HTML/MAN/MAN3/0193____.HTM> 1424 1425Stratus VOS 15.1, 1426L<http://stratadoc.stratus.com/vos/15.1.1/r502-01/wwhelp/wwhimpl/js/html/wwhelp.htm?context=r502-01&file=ch5r502-01bi.html> 1427 1428=head2 RFCs 1429 1430I<RFC 3164 - The BSD syslog Protocol>, L<http://www.faqs.org/rfcs/rfc3164.html> 1431-- Please note that this is an informational RFC, and therefore does not 1432specify a standard of any kind. 1433 1434I<RFC 3195 - Reliable Delivery for syslog>, L<http://www.faqs.org/rfcs/rfc3195.html> 1435 1436=head2 Articles 1437 1438I<Syslogging with Perl>, L<http://lexington.pm.org/meetings/022001.html> 1439 1440=head2 Event Log 1441 1442Windows Event Log, 1443L<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wes/wes/windows_event_log.asp> 1444 1445 1446=head1 AUTHORS & ACKNOWLEDGEMENTS 1447 1448Tom Christiansen E<lt>F<tchrist (at) perl.com>E<gt> and Larry Wall 1449E<lt>F<larry (at) wall.org>E<gt>. 1450 1451UNIX domain sockets added by Sean Robinson 1452E<lt>F<robinson_s (at) sc.maricopa.edu>E<gt> with support from Tim Bunce 1453E<lt>F<Tim.Bunce (at) ig.co.uk>E<gt> and the C<perl5-porters> mailing list. 1454 1455Dependency on F<syslog.ph> replaced with XS code by Tom Hughes 1456E<lt>F<tom (at) compton.nu>E<gt>. 1457 1458Code for C<constant()>s regenerated by Nicholas Clark E<lt>F<nick (at) ccl4.org>E<gt>. 1459 1460Failover to different communication modes by Nick Williams 1461E<lt>F<Nick.Williams (at) morganstanley.com>E<gt>. 1462 1463Extracted from core distribution for publishing on the CPAN by 1464SE<eacute>bastien Aperghis-Tramoni E<lt>sebastien (at) aperghis.netE<gt>. 1465 1466XS code for using native C functions borrowed from C<L<Unix::Syslog>>, 1467written by Marcus Harnisch E<lt>F<marcus.harnisch (at) gmx.net>E<gt>. 1468 1469Yves Orton suggested and helped for making C<Sys::Syslog> use the native 1470event logger under Win32 systems. 1471 1472Jerry D. Hedden and Reini Urban provided greatly appreciated help to 1473debug and polish C<Sys::Syslog> under Cygwin. 1474 1475 1476=head1 BUGS 1477 1478Please report any bugs or feature requests to 1479C<bug-sys-syslog (at) rt.cpan.org>, or through the web interface at 1480L<http://rt.cpan.org/Public/Dist/Display.html?Name=Sys-Syslog>. 1481I will be notified, and then you'll automatically be notified of progress on 1482your bug as I make changes. 1483 1484 1485=head1 SUPPORT 1486 1487You can find documentation for this module with the perldoc command. 1488 1489 perldoc Sys::Syslog 1490 1491You can also look for information at: 1492 1493=over 4 1494 1495=item * AnnoCPAN: Annotated CPAN documentation 1496 1497L<http://annocpan.org/dist/Sys-Syslog> 1498 1499=item * CPAN Ratings 1500 1501L<http://cpanratings.perl.org/d/Sys-Syslog> 1502 1503=item * RT: CPAN's request tracker 1504 1505L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Sys-Syslog> 1506 1507=item * Search CPAN 1508 1509L<http://search.cpan.org/dist/Sys-Syslog/> 1510 1511=item * Kobes' CPAN Search 1512 1513L<http://cpan.uwinnipeg.ca/dist/Sys-Syslog> 1514 1515=item * Perl Documentation 1516 1517L<http://perldoc.perl.org/Sys/Syslog.html> 1518 1519=back 1520 1521 1522=head1 COPYRIGHT 1523 1524Copyright (C) 1990-2008 by Larry Wall and others. 1525 1526 1527=head1 LICENSE 1528 1529This program is free software; you can redistribute it and/or modify it 1530under the same terms as Perl itself. 1531 1532=cut 1533 1534=begin comment 1535 1536Notes for the future maintainer (even if it's still me..) 1537- - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1538 1539Using Google Code Search, I search who on Earth was relying on $host being 1540public. It found 5 hits: 1541 1542* First was inside Indigo Star Perl2exe documentation. Just an old version 1543of Sys::Syslog. 1544 1545 1546* One real hit was inside DalWeathDB, a weather related program. It simply 1547does a 1548 1549 $Sys::Syslog::host = '127.0.0.1'; 1550 1551- L<http://www.gallistel.net/nparker/weather/code/> 1552 1553 1554* Two hits were in TPC, a fax server thingy. It does a 1555 1556 $Sys::Syslog::host = $TPC::LOGHOST; 1557 1558but also has this strange piece of code: 1559 1560 # work around perl5.003 bug 1561 sub Sys::Syslog::hostname {} 1562 1563I don't know what bug the author referred to. 1564 1565- L<http://www.tpc.int/> 1566- L<ftp://ftp.tpc.int/tpc/server/UNIX/> 1567- L<ftp://ftp-usa.tpc.int/pub/tpc/server/UNIX/> 1568 1569 1570* Last hit was in Filefix, which seems to be a FIDOnet mail program (!). 1571This one does not use $host, but has the following piece of code: 1572 1573 sub Sys::Syslog::hostname 1574 { 1575 use Sys::Hostname; 1576 return hostname; 1577 } 1578 1579I guess this was a more elaborate form of the previous bit, maybe because 1580of a bug in Sys::Syslog back then? 1581 1582- L<ftp://ftp.kiae.su/pub/unix/fido/> 1583 1584 1585Links 1586----- 1587Linux Fast-STREAMS 1588- L<http://www.openss7.org/streams.html> 1589 1590II12021: SYSLOGD HOWTO TCPIPINFO (z/OS, OS/390, MVS) 1591- L<http://www-1.ibm.com/support/docview.wss?uid=isg1II12021> 1592 1593Getting the most out of the Event Viewer 1594- L<http://www.codeproject.com/dotnet/evtvwr.asp?print=true> 1595 1596Log events to the Windows NT Event Log with JNI 1597- L<http://www.javaworld.com/javaworld/jw-09-2001/jw-0928-ntmessages.html> 1598 1599=end comment 1600 1601