Skip Menu |

This queue is for tickets about the Net-Daemon CPAN distribution.

Report information
The Basics
Id: 5377
Status: resolved
Priority: 0/
Queue: Net-Daemon

People
Owner: MNOONING [...] cpan.org
Requestors: kevin [...] electron-pc.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Unable to test Net-Daemon successfully
I am trying to install Net::Daemon 0.38 through CPAN (and CPANPLUS) on a NCR/MP-RAS UNIX box and get the following errors during the test: t/config........unix dgram connect: Socket operation on non-socket at blib/lib/Net/Daemon/Log.pm line 114 no connection to syslog available at blib/lib/Net/Daemon/Log.pm line 114 If I run a simple test script of Sys::Syslog it runs and works just fine: #!/usr/bin/perl -w use Sys::Syslog; $program="Test Program"; openlog($program, 'cons,pid', 'user'); syslog('info', 'this is another test'); syslog('mail|warning', 'this is a better test: %d', time); closelog(); Here's some info about my box: uname -a name name 4.0 3.0 3516 Pentium IV(TM)-ISA/PCI perl -v v5.8.3 built for 3516-svr4.0 Thanks for your help. Let me know what you need to figure out the problem. Kevin
Your example script doesn't do quite the same than Net::Daemon: The latter uses the setlogsock('unix') call. Jochen
From: kevin [...] electron-pc.com
Show quoted text
> > Your example script doesn't do quite the same than Net::Daemon: The latter > uses the setlogsock('unix') call. > > > Jochen
So do you have any recommendations on how I might be able to install Net-Daemon successfully? Is there a simple script I could run that would be able to replicate the problem? I guess I just don't really know what is failing here to know what I need to change to fix it. Kevin
Either of the following: * Proceed to install and use a different logging method than syslog. * Enquire why setlogsock('unix') doesn't work on your system. * Play with the "Log" module until you have a working test case. (It isn't that difficult at all.) At that point proceed to install, possibly coming up with a patch, if you think that something's wrong.
From: duston [...] ll.mit.edu
[guest - Wed Feb 18 15:49:56 2004]: I also get this error on an SGI Irix platform. I needed to get this working since it is a prerequisite to installing the DBI and DBD::Oracle modules. I do not see this error on Perl 5.8.0, but do on Perl 5.8.5 and above. It could also be since Sys::syslog changed from 0.3 to 0.5. In any case, I noted a blurb in the Sys::sylog document (see http://search.cpan.org/~nwclark/perl-5.8.6/ext/Sys/Syslog/Syslog.pm) that Irix and Solaris require setlogsock('stream') instead of 'unix'. Please find attached my fix to Log.pm in sub OpenLog for the Irix platform. I do not have a Solaris to test on, but if &Sys::Syslog::_PATH_LOG() works on Solaris, you may want to consider changing the if loop to: if ($^O ne 'freebsd' && defined(&Sys::Syslog::setlogsock) && eval { &Sys::Syslog::_PATH_LOG() }) { if ($^O ne 'irix' && $^0 ne 'solaris') { &Sys::Syslog::setlogsock('unix'); } else { &Sys::Syslog::setlogsock('stream'); } } I can't tell from the original poster's info what platform he is running, would that be freebsd? If it s in the same situation that could be moved to the inner if loop also but I didn't see anything in the Sys::syslog document if it uses 'unix' or 'stream'. Additional notes: some MicroSoft ^M characters are in the Log subroutine, could be cleaned up. Should $Net::Daemon::Log::VERSION = '0.01'; be incremented since this pm has been modified? Thanks, Jack Show quoted text
> I am trying to install Net::Daemon 0.38 through CPAN (and CPANPLUS)
on Show quoted text
> a NCR/MP-RAS UNIX box and get the following errors during the
test: Show quoted text
> > t/config........unix dgram connect: Socket operation on non-socket at > blib/lib/Net/Daemon/Log.pm line 114 > no connection to syslog available at blib/lib/Net/Daemon/Log.pm line > 114 > > If I run a simple test script of Sys::Syslog it runs and works just > fine: > > #!/usr/bin/perl -w > > use Sys::Syslog; > > $program="Test Program"; > openlog($program, 'cons,pid', 'user'); > syslog('info', 'this is another test'); > syslog('mail|warning', 'this is a better test: %d', time); > closelog(); > > Here's some info about my box: > > uname -a > name name 4.0 3.0 3516 Pentium IV(TM)-ISA/PCI > > perl -v > v5.8.3 built for 3516-svr4.0 > > Thanks for your help. Let me know what you need to figure out the > problem. > > Kevin
# -*- perl -*- # # $Id: Log.pm,v 1.3 1999/09/26 14:50:13 joe Exp $ # # Net::Daemon - Base class for implementing TCP/IP daemons # # Copyright (C) 1998, Jochen Wiedmann # Am Eisteich 9 # 72555 Metzingen # Germany # # Phone: +49 7123 14887 # Email: joe@ispsoft.de # # All rights reserved. # # You may distribute this package under the terms of either the GNU # General Public License or the Artistic License, as specified in the # Perl README file. # ############################################################################ require 5.004; use strict; package Net::Daemon::Log; $Net::Daemon::Log::VERSION = '0.01'; ############################################################################ # # Name: Log (Instance method) # # Purpose: Does logging # # Inputs: $self - Server instance # # Result: TRUE, if the client has successfully authorized, FALSE # otherwise. # ############################################################################ sub OpenLog($) { my $self = shift; return 1 unless ref($self); return $self->{'logfile'} if defined($self->{'logfile'}); if ($Config::Config{'archname'} =~ /win32/i) { require Win32::EventLog; $self->{'eventLog'} = Win32::EventLog->new(ref($self), '') or die "Cannot open EventLog:" . &Win32::GetLastError(); $self->{'$eventId'} = 0; } else { eval { require Sys::Syslog }; if ($@) { die "Cannot open Syslog: $@"; } if ($^O ne 'solaris' && $^O ne 'freebsd' && defined(&Sys::Syslog::setlogsock) && eval { &Sys::Syslog::_PATH_LOG() }) { if ($^O ne 'irix') { &Sys::Syslog::setlogsock('unix'); } else { &Sys::Syslog::setlogsock('stream'); } } &Sys::Syslog::openlog($self->{'logname'} || ref($self), 'pid', $self->{'facility'} || 'daemon'); } $self->{'logfile'} = 0; } sub Log ($$$;@) { my($self, $level, $format, @args) = @_; my $logfile = !ref($self) || $self->OpenLog(); my $tid = ''; if (ref($self) && $self->{'mode'}) { if ($self->{'mode'} eq 'ithreads') { if (my $sthread = threads->self()) { $tid = $sthread->tid() . ", "; } } elsif ($self->{'mode'} eq 'threads') { if (my $sthread = Thread->self()) { $tid = $sthread->tid() . ", "; } } } if ($logfile) { my $logtime = $self->LogTime(); if (ref($logfile)) { $logfile->print(sprintf("$logtime $level, $tid$format\n", @args)); } else { printf STDERR ("$logtime $level, $tid$format\n", @args); } } elsif (my $eventLog = $self->{'eventLog'}) { my($type, $category); if ($level eq 'debug') { $type = Win32::EventLog::EVENTLOG_INFORMATION_TYPE(); $category = 10; } elsif ($level eq 'notice') { $type = Win32::EventLog::EVENTLOG_INFORMATION_TYPE(); $category = 20; } else { $type = Win32::EventLog::EVENTLOG_ERROR_TYPE(); $category = 50; } $eventLog->Report({ 'Category' => $category, 'EventType' => $type, 'EventID' => ++$self->{'eventId'}, 'Strings' => sprintf($format, @args), 'Data' => $tid }); } else { &Sys::Syslog::syslog($level, "$tid$format", @args); } } sub Debug ($$;@) { my $self = shift; if (!ref($self) || $self->{'debug'}) { my $fmt = shift; $self->Log('debug', $fmt, @_); } } sub Error ($$;@) { my $self = shift; my $fmt = shift; $self->Log('err', $fmt, @_); } sub Fatal ($$;@) { my $self = shift; my $fmt = shift; my $msg = sprintf($fmt, @_); $self->Log('err', $msg); my($package, $filename, $line) = caller(); die "$msg at $filename line $line."; } sub LogTime { scalar(localtime) } 1; __END__ =head1 NAME Net::Daemon::Log - Utility functions for logging =head1 SYNOPSIS # Choose logging method: syslog or Win32::EventLog $self->{'facility'} = 'mail'; # Default: Daemon $self->{'logfile'} = undef; # Default # Choose logging method: stderr $self->{'logfile'} = 1; # Choose logging method: IO handle my $file = IO::File->new("my.log", "a"); $self->{'logfile'} = $file; # Debugging messages (equivalent): $self->Log('debug', "This is a debugging message"); $self->Debug("This is a debugging message"); # Error messages (equivalent): $self->Log('err', "This is an error message"); $self->Error("This is an error message"); # Fatal error messages (implies 'die') $self->Fatal("This is a fatal error message"); =head1 WARNING THIS IS ALPHA SOFTWARE. It is *only* 'Alpha' because the interface (API) is not finalised. The Alpha status does not reflect code quality or stability. =head1 DESCRIPTION Net::Daemon::Log is a utility class for portable logging messages. By default it uses syslog (Unix) or Win32::EventLog (Windows), but logging messages can also be redirected to stderr or a log file. =head2 Generic Logging $self->Log($level, $msg, @args); This is the generic interface. The logging level is in syslog style, thus one of the words 'debug', 'info', 'notice', 'err' or 'crit'. You'll rarely need info and notice and I can hardly imagine a reason for crit (critical). In 95% of all cases debug and err will be sufficient. The logging string $msg is a format string similar to printf. =head2 Utility methods $self->Debug($msg, @args); $self->Error($msg, @args); $self->Fatal($msg, @args); These are replacements for logging with levels debug and err. The difference between the latter two is that Fatal includes throwing a Perl exception. =head2 Chossing a logging target By default logging will happen to syslog (Unix) or EventLog (Windows). However you may choose logging to stderr by setting $self->{'logfile'} = 1; This is required if neither of syslog and EventLog is available. An alternative option is setting $self->{'logfile'} = $handle; where $handle is any object supporting a I<print> method, for example an IO::Handle object. Usually the logging target is choosen as soon as you call $self->Log() the first time. However, you may force choosing the target by doing a $self->OpenLog(); before calling Log the first time. =head1 MULTITHREADING The Multithreading capabitities of this class are depending heavily on the underlying classes Sys::Syslog, Win32::EventLog or IO::Handle. If they are thread safe, you can well assume that this package is too. (The exception being that you should better call $self->OpenLog() before threading.) =head1 AUTHOR AND COPYRIGHT Net::Daemon is Copyright (C) 1998, Jochen Wiedmann Am Eisteich 9 72555 Metzingen Germany Phone: +49 7123 14887 Email: joe@ispsoft.de All rights reserved. You may distribute this package under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. =head1 SEE ALSO L<Net::Daemon(3)>, L<Sys::Syslog(3)>, L<Win32::EventLog(3)>, L<IO::Handle(3)> =cut
This bug is three years old, and the revision is up to Net-Daemon-0.41 now. I did nothing to fix this specific bug but Net-Daemon now works on Windows. It had not for likewise three years. Even if the bugs were not related, I would like to see this bug repeated with new versions of Perl and Net-Daemon before working on it. It may already be fixed. Thanks