/[meteor]/googlecode.com/svn/trunk/Meteor/Syslog.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /googlecode.com/svn/trunk/Meteor/Syslog.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 50 - (hide annotations)
Wed Feb 27 13:55:35 2008 UTC (12 years, 1 month ago) by andrew.betts
File size: 3096 byte(s)
Added crossdomain.xml for flash clients
Incremented version number
Moved 'new message' debug notice to more useful location
Moved default for ChannelInfoTemplate to correct position alphabetically in code
Set simpler default HeaderTemplate
Added LogTimeFormat
Updated description of PingInterval, Persist
Corrected misspelling of Parameter
Reformatted debug output for config initialisation
Added recognition of null byte in config
Fixed problem with mode recognition
Fixed resuming from given message ID
Fixed sending of message backlog
Fixed Shlemiels
Logged connection duration on leavechannel
Fixed name support in channelinfotemplate
Added logging of reasons for connection closes
Abbreviated log output
Fixed tracking of subscriber IDs
Added logging of user agent
Fixed incorrect key for MessageTemplate in Subscriber.pm
Add some additional code comments
Fixed incorrect closure of new connection if previous connection close was waiting on write buffer

1 knops.gerd 11 #!/usr/bin/perl -w
2     ###############################################################################
3     # Meteor
4     # An HTTP server for the 2.0 web
5     # Copyright (c) 2006 contributing authors
6     #
7     # Subscriber.pm
8     #
9     # Description:
10     # Convenience interface to syslog
11     #
12     ###############################################################################
13     #
14     # This program is free software; you can redistribute it and/or modify it
15     # under the terms of the GNU General Public License as published by the Free
16     # Software Foundation; either version 2 of the License, or (at your option)
17     # any later version.
18     #
19     # This program is distributed in the hope that it will be useful, but WITHOUT
20     # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21     # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
22     # more details.
23     #
24     # You should have received a copy of the GNU General Public License along
25     # with this program; if not, write to the Free Software Foundation, Inc.,
26     # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27     #
28     # For more information visit www.meteorserver.org
29     #
30     ###############################################################################
31    
32     package Meteor::Syslog;
33     ###############################################################################
34    
35     use strict;
36     use Sys::Syslog;
37    
38     ###############################################################################
39     # Configuration
40     ###############################################################################
41    
42     $Meteor::Syslog::DEFAULT_FACILITY='daemon';
43    
44     $Meteor::Syslog::_open=0; # set to 1 by _open
45    
46     ###############################################################################
47     # Implementation
48     ###############################################################################
49     sub ::syslog {
50    
51 knops.gerd 47 my $debug=$::CONF{'Debug'};
52    
53     my $priority=shift;
54     return if($priority eq 'debug' && !$debug);
55    
56     my $format=shift;
57     my @args=@_;
58    
59     if($format eq '')
60 knops.gerd 11 {
61 knops.gerd 47 my $txt=join("\t",@args);
62     $format='%s';
63     @args=($txt);
64     }
65    
66     my $facility=$::CONF{'SyslogFacility'} || $Meteor::Syslog::DEFAULT_FACILITY;
67    
68     if($debug || $facility eq 'none')
69     {
70 knops.gerd 11 $format=~s/\%m/$!/g;
71    
72 andrew.betts 50 my $time = ($::CONF{'LogTimeFormat'} eq 'unix') ? time : localtime(time);
73 knops.gerd 47
74 andrew.betts 50 print STDERR "$time\t$priority\t";
75     print STDERR sprintf($format,@args);
76 knops.gerd 11 print STDERR "\n" unless(substr($format,-1) eq "\n");
77    
78     return;
79     }
80    
81     unless($Meteor::Syslog::_open)
82     {
83     my $facility=$::CONF{'SyslogFacility'} || $Meteor::Syslog::DEFAULT_FACILITY;
84     openlog($::PGM,0,$facility);
85     $Meteor::Syslog::_open=1;
86     }
87    
88 knops.gerd 47 syslog($priority,$format,@args);
89 knops.gerd 11 }
90    
91     sub myWarn {
92     local $SIG{'__DIE__'}='';
93     local $SIG{'__WARN__'}='';
94    
95     &::syslog('warning',$_[0]);
96     }
97    
98     sub myDie {
99     local $SIG{'__DIE__'}='';
100     local $SIG{'__WARN__'}='';
101    
102     my $inEval=0;
103     my $i=0;
104     my $sub;
105     while((undef,undef,undef,$sub)=caller(++$i))
106     {
107     $inEval=1, last if $sub eq '(eval)';
108     }
109    
110     unless($inEval)
111     {
112     &::syslog('err',$_[0]);
113     $Meteor::Socket::NO_WARN_ON_CLOSE=1;
114     exit;
115     }
116     }
117    
118     1;
119 andrew.betts 3 ############################################################################EOF

  ViewVC Help
Powered by ViewVC 1.1.26