-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://svn.sixapart.com/repos/eng/modules/Log-Syslog-Constants/trunk@117757 f3b680aa-fef1-0310-ac4d-b15a123b9462
- Loading branch information
athomason
committed
Jan 11, 2010
0 parents
commit 340855c
Showing
10 changed files
with
439 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# auto-generated shipit config file. | ||
steps = FindVersion, ChangeVersion, CheckChangeLog, DistTest, Commit, Tag, MakeDist, UploadCPAN | ||
|
||
svn.tagpattern = http://svn.sixapart.com/repos/eng/modules/Log-Syslog-Constants/tags/Log-Syslog-Constants-%v | ||
|
||
CheckChangeLog.files = Changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Revision history for Perl extension Log::Syslog::Constants. | ||
1.00 Mon Jan 11 12:30:21 PST 2010 | ||
- Initial revision, ripped out from Log::Syslog::Fast |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
%define pkgname Log-Syslog-Constants | ||
%define filelist %{pkgname}-%{version}-filelist | ||
%define NVR %{pkgname}-%{version}-%{release} | ||
%define maketest 1 | ||
%define VERSION %(grep 'VERSION =' lib/Log/Syslog/Constants.pm | perl -nle '/([0-9.]+)/ && print $1') | ||
|
||
name: perl-Log-Syslog-Constants | ||
summary: Log-Syslog-Constants - Log::Syslog::Constants - Perl extension for sending syslog messages over TCP or UDP with minimal CPU overhead. | ||
version: %{VERSION} | ||
release: 1 | ||
vendor: Adam Thomason <athomason@sixapart.com> | ||
packager: Arix International <cpan2rpm@arix.com> | ||
license: Artistic | ||
group: Applications/CPAN | ||
url: http://www.cpan.org | ||
buildroot: %{_tmppath}/%{name}-%{version}-%(id -u -n) | ||
buildarch: x86_64 | ||
prefix: %(echo %{_prefix}) | ||
source: Log-Syslog-Constants-%{version}.tar.gz | ||
|
||
%description | ||
This module sends syslog messages over a network socket. | ||
|
||
# | ||
# This package was generated automatically with the cpan2rpm | ||
# utility. To get this software or for more information | ||
# please visit: http://perl.arix.com/ | ||
# | ||
|
||
%prep | ||
%setup -q -n %{pkgname}-%{version} | ||
chmod -R u+w %{_builddir}/%{pkgname}-%{version} | ||
|
||
%build | ||
grep -rsl '^#!.*perl' . | | ||
grep -v '.bak$' |xargs --no-run-if-empty \ | ||
%__perl -MExtUtils::MakeMaker -e 'MY->fixin(@ARGV)' | ||
CFLAGS="$RPM_OPT_FLAGS" | ||
%{__perl} Makefile.PL `%{__perl} -MExtUtils::MakeMaker -e ' print qq|PREFIX=%{buildroot}%{_prefix}| if \$ExtUtils::MakeMaker::VERSION =~ /5\.9[1-6]|6\.0[0-5]/ '` | ||
%{__make} | ||
%if %maketest | ||
%{__make} test | ||
%endif | ||
|
||
%install | ||
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot} | ||
|
||
%{makeinstall} `%{__perl} -MExtUtils::MakeMaker -e ' print \$ExtUtils::MakeMaker::VERSION <= 6.05 ? qq|PREFIX=%{buildroot}%{_prefix}| : qq|DESTDIR=%{buildroot}| '` | ||
|
||
cmd=/usr/share/spec-helper/compress_files | ||
[ -x $cmd ] || cmd=/usr/lib/rpm/brp-compress | ||
[ -x $cmd ] && $cmd | ||
|
||
# SuSE Linux | ||
if [ -e /etc/SuSE-release -o -e /etc/UnitedLinux-release ] | ||
then | ||
%{__mkdir_p} %{buildroot}/var/adm/perl-modules | ||
%{__cat} `find %{buildroot} -name "perllocal.pod"` \ | ||
| %{__sed} -e s+%{buildroot}++g \ | ||
> %{buildroot}/var/adm/perl-modules/%{name} | ||
fi | ||
|
||
# remove special files | ||
find %{buildroot} -name "perllocal.pod" \ | ||
-o -name ".packlist" \ | ||
-o -name "*.bs" \ | ||
|xargs -i rm -f {} | ||
|
||
# no empty directories | ||
find %{buildroot}%{_prefix} \ | ||
-type d -depth \ | ||
-exec rmdir {} \; 2>/dev/null | ||
|
||
%{__perl} -MFile::Find -le ' | ||
find({ wanted => \&wanted, no_chdir => 1}, "%{buildroot}"); | ||
print "%doc Changes README"; | ||
for my $x (sort @dirs, @files) { | ||
push @ret, $x unless indirs($x); | ||
} | ||
print join "\n", sort @ret; | ||
|
||
sub wanted { | ||
return if /auto$/; | ||
|
||
local $_ = $File::Find::name; | ||
my $f = $_; s|^\Q%{buildroot}\E||; | ||
return unless length; | ||
return $files[@files] = $_ if -f $f; | ||
|
||
$d = $_; | ||
/\Q$d\E/ && return for reverse sort @INC; | ||
$d =~ /\Q$_\E/ && return | ||
for qw|/etc %_prefix/man %_prefix/bin %_prefix/share|; | ||
|
||
$dirs[@dirs] = $_; | ||
} | ||
|
||
sub indirs { | ||
my $x = shift; | ||
$x =~ /^\Q$_\E\// && $x ne $_ && return 1 for @dirs; | ||
} | ||
' > %filelist | ||
|
||
[ -z %filelist ] && { | ||
echo "ERROR: empty %files listing" | ||
exit -1 | ||
} | ||
|
||
%clean | ||
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot} | ||
|
||
%files -f %filelist | ||
%defattr(-,root,root) | ||
|
||
%changelog | ||
* Mon Jan 11 2010 athomason@athomason-many | ||
- Initial build. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.shipit | ||
Changes | ||
Makefile.PL | ||
MANIFEST | ||
MANIFEST.SKIP | ||
README | ||
t/Log-Syslog-Constants.t | ||
lib/Log/Syslog/Constants.pm | ||
META.yml Module meta-data (added by MakeMaker) | ||
Log-Syslog-Constants.spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.svn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# http://module-build.sourceforge.net/META-spec.html | ||
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# | ||
name: Log-Syslog-Constants | ||
version: 1.00 | ||
version_from: lib/Log/Syslog/Constants.pm | ||
installdirs: site | ||
requires: | ||
|
||
distribution_type: module | ||
generated_by: ExtUtils::MakeMaker version 6.17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use 5.008000; | ||
use ExtUtils::MakeMaker; | ||
WriteMakefile( | ||
NAME => 'Log::Syslog::Constants', | ||
VERSION_FROM => 'lib/Log/Syslog/Constants.pm', | ||
ABSTRACT_FROM => 'lib/Log/Syslog/Constants.pm', | ||
AUTHOR => 'Adam Thomason <athomason@sixapart.com>', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Log-Syslog-Constants version 1.00 | ||
================================= | ||
|
||
The README is used to introduce the module and provide instructions on | ||
how to install the module, any machine dependencies it may have (for | ||
example C compilers and installed libraries) and any other information | ||
that should be provided before the module is installed. | ||
|
||
A README file is required for CPAN modules since CPAN extracts the | ||
README file from a module distribution so that people browsing the | ||
archive can use it get an idea of the modules uses. It is usually a | ||
good idea to provide version information here so that people can | ||
decide whether fixes for the module are worth downloading. | ||
|
||
INSTALLATION | ||
|
||
To install this module type the following: | ||
|
||
perl Makefile.PL | ||
make | ||
make test | ||
make install | ||
|
||
COPYRIGHT AND LICENCE | ||
|
||
Copyright (C) 2010 by Six Apart, Ltd. | ||
|
||
This library is free software; you can redistribute it and/or modify | ||
it under the same terms as Perl itself, either Perl version 5.8.5 or, | ||
at your option, any later version of Perl 5 you may have available. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
package Log::Syslog::Constants; | ||
|
||
use 5.008000; | ||
use strict; | ||
use warnings; | ||
|
||
our $VERSION = '1.00'; | ||
|
||
use constant { | ||
# severities | ||
LOG_EMERG => 0, # system is unusable | ||
LOG_ALERT => 1, # action must be taken immediately | ||
LOG_CRIT => 2, # critical conditions | ||
LOG_ERR => 3, # error conditions | ||
LOG_WARNING => 4, # warning conditions | ||
LOG_NOTICE => 5, # normal but significant condition | ||
LOG_INFO => 6, # informational | ||
LOG_DEBUG => 7, # debug-level messages | ||
|
||
# facilities | ||
LOG_KERN => 0, # kernel messages | ||
LOG_USER => 1, # random user-level messages | ||
LOG_MAIL => 2, # mail system | ||
LOG_DAEMON => 3, # system daemons | ||
LOG_AUTH => 4, # security/authorization messages | ||
LOG_SYSLOG => 5, # messages generated internally by syslogd | ||
LOG_LPR => 6, # line printer subsystem | ||
LOG_NEWS => 7, # network news subsystem | ||
LOG_UUCP => 8, # UUCP subsystem | ||
LOG_CRON => 9, # clock daemon | ||
LOG_AUTHPRIV => 10, # security/authorization messages (private) | ||
LOG_FTP => 11, # ftp daemon | ||
LOG_LOCAL0 => 16, # reserved for local use | ||
LOG_LOCAL1 => 17, # reserved for local use | ||
LOG_LOCAL2 => 18, # reserved for local use | ||
LOG_LOCAL3 => 19, # reserved for local use | ||
LOG_LOCAL4 => 20, # reserved for local use | ||
LOG_LOCAL5 => 21, # reserved for local use | ||
LOG_LOCAL6 => 22, # reserved for local use | ||
LOG_LOCAL7 => 23, # reserved for local use | ||
}; | ||
|
||
my %_severities_by_name = ( | ||
emerg => LOG_EMERG, | ||
alert => LOG_ALERT, | ||
crit => LOG_CRIT, | ||
err => LOG_ERR, | ||
warning => LOG_WARNING, | ||
notice => LOG_NOTICE, | ||
info => LOG_INFO, | ||
debug => LOG_DEBUG, | ||
); | ||
|
||
my %_facilities_by_name = ( | ||
kern => LOG_KERN, | ||
user => LOG_USER, | ||
mail => LOG_MAIL, | ||
daemon => LOG_DAEMON, | ||
auth => LOG_AUTH, | ||
syslog => LOG_SYSLOG, | ||
lpr => LOG_LPR, | ||
news => LOG_NEWS, | ||
uucp => LOG_UUCP, | ||
cron => LOG_CRON, | ||
authpriv => LOG_AUTHPRIV, | ||
ftp => LOG_FTP, | ||
local0 => LOG_LOCAL0, | ||
local1 => LOG_LOCAL1, | ||
local2 => LOG_LOCAL2, | ||
local3 => LOG_LOCAL3, | ||
local4 => LOG_LOCAL4, | ||
local5 => LOG_LOCAL5, | ||
local6 => LOG_LOCAL6, | ||
local7 => LOG_LOCAL7, | ||
); | ||
|
||
sub get_severity { | ||
$_severities_by_name{lc $_[0]}; | ||
} | ||
|
||
sub get_facility { | ||
$_facilities_by_name{lc $_[0]}; | ||
} | ||
|
||
require Exporter; | ||
|
||
our @ISA = qw(Exporter); | ||
|
||
our %EXPORT_TAGS = ( | ||
severities => [qw/ | ||
LOG_EMERG LOG_ALERT LOG_CRIT LOG_ERR LOG_WARNING | ||
LOG_NOTICE LOG_INFO LOG_DEBUG | ||
/], | ||
facilities => [qw/ | ||
LOG_KERN LOG_USER LOG_MAIL LOG_DAEMON LOG_AUTH | ||
LOG_SYSLOG LOG_LPR LOG_NEWS LOG_UUCP LOG_CRON | ||
LOG_AUTHPRIV LOG_FTP LOG_LOCAL0 LOG_LOCAL1 LOG_LOCAL2 | ||
LOG_LOCAL3 LOG_LOCAL4 LOG_LOCAL5 LOG_LOCAL6 LOG_LOCAL7 | ||
/], | ||
functions => [qw/ | ||
get_severity get_facility | ||
/], | ||
); | ||
@{ $EXPORT_TAGS{'all'} } = ( | ||
@{ $EXPORT_TAGS{'facilities'} }, | ||
@{ $EXPORT_TAGS{'severities'} }, | ||
@{ $EXPORT_TAGS{'functions'} }, | ||
); | ||
|
||
our @EXPORT_OK = @{ $EXPORT_TAGS{'all'} }; | ||
our @EXPORT = qw(); | ||
|
||
1; | ||
|
||
__END__ | ||
=head1 NAME | ||
Log::Syslog::Constants - Perl extension containing syslog priority constants as | ||
defined in RFC3164. | ||
=head1 SYNOPSIS | ||
use Log::Syslog::Constants ':all'; | ||
my @severities = ( | ||
LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, | ||
LOG_DEBUG | ||
); | ||
@facilities = ( | ||
LOG_KERN, LOG_USER, LOG_MAIL, LOG_DAEMON, LOG_AUTH, LOG_SYSLOG, LOG_LPR, | ||
LOG_NEWS, LOG_UUCP, LOG_CRON, LOG_AUTHPRIV, LOG_FTP, LOG_LOCAL0, | ||
LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, | ||
LOG_LOCAL7 | ||
); | ||
$info_constant = get_severity('INFO'); | ||
$local0_constant = get_severity('local0'); | ||
=head1 DESCRIPTION | ||
Syslog messages as standardized in RFC3164 embed a priority number (the PRI | ||
part) which is composed of a severity and a facility value. The constants which | ||
encode these values are specified in section 4.1.1, and are made available by | ||
this module. For instance, the LOG_FTP exported constant has a value of 11, the | ||
value for the FTP facility. | ||
=head1 EXPORTS | ||
Nothing is exported by default. You may optionally import individual constants, | ||
all constants for severity and facility levels, or all of them. | ||
use Log::Syslog::Constants qw(:severities); # LOG_CRIT, LOG_NOTICE, LOG_DEBUG, etc | ||
use Log::Syslog::Constants qw(:facilities); # LOG_CRON, LOG_LOCAL3, etc | ||
use Log::Syslog::Constants qw(:functions); # get_facility, get_severity | ||
use Log::Syslog::Constants qw(:all); # all of the above | ||
=head1 FUNCTIONS | ||
=over 4 | ||
=item * get_facility | ||
=item * get_severity | ||
These functions may be used to get the constants by string name, e.g. | ||
get_severity('info') == LOG_INFO. | ||
=back | ||
=head1 AUTHOR | ||
Adam Thomason, E<lt>athomason@sixapart.comE<gt> | ||
=head1 COPYRIGHT AND LICENSE | ||
Copyright (C) 2010 by Six Apart, Ltd. | ||
This library is free software; you can redistribute it and/or modify | ||
it under the same terms as Perl itself, either Perl version 5.8.5 or, | ||
at your option, any later version of Perl 5 you may have available. | ||
=cut |
Oops, something went wrong.