File Coverage

blib/lib/Unix/Syslog.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 15 15 100.0


line stmt bran cond sub pod time code
1             # $Id: Syslog.pm,v 1.12 2008/05/18 19:26:54 marcus Exp $
2             #
3             # Copyright (c) 1999,2000,2001,2002,2007 Marcus Harnisch
4             #
5             # This program is free software; you can redistribute it and/or modify
6             # it under the terms of the Artistic License 2.0 (see file Artistic in
7             # this directory).
8             #
9             # Check clause (4) for your rights to distribute this software.
10              
11             package Unix::Syslog;
12              
13 1     1   909 use strict;
  1         2  
  1         40  
14 1     1   39 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
  1         2  
  1         389  
15              
16             require Exporter;
17             require DynaLoader;
18              
19             @ISA = qw(Exporter DynaLoader);
20             # Items to export into callers namespace by default. Note: do not export
21             # names by default without a very good reason. Use EXPORT_OK instead.
22             # Do not simply export all your public functions/methods/constants.
23              
24             @EXPORT_OK = qw(LOG_EMERG LOG_ALERT LOG_CRIT LOG_ERR LOG_WARNING LOG_NOTICE
25             LOG_INFO LOG_DEBUG LOG_KERN LOG_USER LOG_MAIL LOG_DAEMON
26             LOG_AUTH LOG_SYSLOG LOG_LPR LOG_NEWS LOG_UUCP LOG_CRON
27             LOG_AUTHPRIV LOG_FTP LOG_LOCAL0 LOG_LOCAL1 LOG_LOCAL2
28             LOG_LOCAL3 LOG_LOCAL4 LOG_LOCAL5 LOG_LOCAL6 LOG_LOCAL7
29             LOG_PID LOG_CONS LOG_ODELAY LOG_NDELAY LOG_NOWAIT LOG_PERROR
30             LOG_NFACILITIES LOG_FACMASK LOG_FAC LOG_MASK LOG_PRI LOG_UPTO
31             LOG_MAKEPRI closelog openlog syslog setlogmask priorityname
32             facilityname);
33              
34             %EXPORT_TAGS = ("macros" => [qw(LOG_EMERG LOG_ALERT LOG_CRIT LOG_ERR
35             LOG_WARNING LOG_NOTICE LOG_INFO LOG_DEBUG
36             LOG_KERN LOG_USER LOG_MAIL LOG_DAEMON LOG_AUTH
37             LOG_SYSLOG LOG_LPR LOG_NEWS LOG_UUCP LOG_CRON
38             LOG_AUTHPRIV LOG_FTP LOG_LOCAL0 LOG_LOCAL1
39             LOG_LOCAL2 LOG_LOCAL3 LOG_LOCAL4 LOG_LOCAL5
40             LOG_LOCAL6 LOG_LOCAL7 LOG_PID LOG_CONS
41             LOG_ODELAY LOG_NDELAY LOG_NOWAIT LOG_PERROR
42             LOG_NFACILITIES LOG_FACMASK LOG_FAC LOG_MASK
43             LOG_PRI LOG_UPTO LOG_MAKEPRI)],
44             "subs" => [qw(closelog openlog syslog setlogmask priorityname
45             facilityname)]);
46              
47             $VERSION = '1.1';
48              
49             bootstrap Unix::Syslog $VERSION;
50              
51             # Preloaded methods go here.
52              
53             sub syslog($$@) {
54 13     13 1 6355 my $priority = shift;
55 13         18 my $format = shift;
56              
57 13         135 $format =~ s/((?:[^%]|^)(?:%%)*)%m/$1$!/g;
58              
59 13         41 my $msg = sprintf($format,@_);
60              
61 13         603 _isyslog($priority, $msg);
62             }
63              
64             # openlog, closelog and setlogmask don't need a wrapper
65              
66             1;
67             __END__