| 1 | package Log::Syslog::Fast::Simple; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Log::Syslog::Fast ':all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Sys::Hostname; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 2 | require Exporter; | |||||||||||||||||||||||||||
| 10 | 2 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 11 | 2 | our @EXPORT = qw(); | |||||||||||||||||||||||||||
| 12 | 2 | our %EXPORT_TAGS = %Log::Syslog::Fast::Constants::EXPORT_TAGS; | |||||||||||||||||||||||||||
| 13 | 2 | our @EXPORT_OK = @Log::Syslog::Fast::Constants::EXPORT_OK; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use constant _LOGGERS => 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use constant _ARGS => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use constant _PROTO => 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use constant _HOSTNAME => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use constant _PORT => 2; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use constant _FACILITY => 3; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use constant _SEVERITY => 4; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use constant _SENDER => 5; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use constant _NAME => 6; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use constant _FORMAT => 7; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=12 SCAR=27.0
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 2 | my $what = shift; | |||||||||||||||||||||||||||
| 29 | 2 | ▶ | my $class = ref $what || $what; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $what || $what
MC/DC0%0/2
ref $what || $what
ref $what
$what
Truth table33%1/3
A || B
A= ref $whatB= $what
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 2 | my $default_name = $0; | |||||||||||||||||||||||||||
| 32 | 2 | $default_name =~ s,.*/,,; | |||||||||||||||||||||||||||
| 33 | 2 | $default_name =~ s/[^\w.-_]//g; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 2 | ▶ | my $args = (@_ == 1 && ref $_[0] eq 'HASH') ? $_[0] : {@_}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 2 | ▶ | $args->{proto} ||= LOG_UDP; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args->{"proto"} ||= 0
MC/DC0%0/1
$args->{"proto"} ||= 0
$args->{"proto"}
Truth table50%1/2
A
A= $args->{"proto"}
| |||||||||||||||||||||||||||||
| 38 | 2 | ▶ | $args->{hostname} ||= '127.0.0.1'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args->{"hostname"} ||= "127.0.0.1"
MC/DC0%0/1
$args->{"hostname"} ||= "127.0.0.1"
$args->{"hostname"}
Truth table50%1/2
A
A= $args->{"hostname"}
| |||||||||||||||||||||||||||||
| 39 | 2 | ▶ | $args->{port} ||= 514; | ||||||||||||||||||||||||||
|
Condition100%2/2
$args->{"port"} ||= 514
MC/DC100%1/1
$args->{"port"} ||= 514
$args->{"port"}
Truth table100%2/2
A
A= $args->{"port"}
| |||||||||||||||||||||||||||||
| 40 | 2 | ▶ | $args->{facility} ||= LOG_LOCAL0; | ||||||||||||||||||||||||||
|
Condition66%2/3
$args->{"facility"} ||= LOG_LOCAL0()
MC/DC0%0/2
$args->{"facility"} ||= LOG_LOCAL0()
$args->{"facility"}
LOG_LOCAL0()
Truth table66%2/3
A ||= B
A= $args->{"facility"}B= LOG_LOCAL0()
| |||||||||||||||||||||||||||||
| 41 | 2 | ▶ | $args->{severity} ||= LOG_INFO; | ||||||||||||||||||||||||||
|
Condition66%2/3
$args->{"severity"} ||= LOG_INFO()
MC/DC0%0/2
$args->{"severity"} ||= LOG_INFO()
$args->{"severity"}
LOG_INFO()
Truth table66%2/3
A ||= B
A= $args->{"severity"}B= LOG_INFO()
| |||||||||||||||||||||||||||||
| 42 | 2 | ▶ | $args->{sender} ||= Sys::Hostname::hostname; | ||||||||||||||||||||||||||
|
Condition66%2/3
$args->{"sender"} ||= Sys::Hostname::hostname()
MC/DC0%0/2
$args->{"sender"} ||= Sys::Hostname::hostname()
$args->{"sender"}
Sys::Hostname::hostname()
Truth table66%2/3
A ||= B
A= $args->{"sender"}B= Sys::Hostname::hostname()
| |||||||||||||||||||||||||||||
| 43 | 2 | ▶ | $args->{name} ||= $default_name; | ||||||||||||||||||||||||||
|
Condition66%2/3
$args->{"name"} ||= $default_name
MC/DC0%0/2
$args->{"name"} ||= $default_name
$args->{"name"}
$default_name
Truth table66%2/3
A ||= B
A= $args->{"name"}B= $default_name
| |||||||||||||||||||||||||||||
| 44 | 2 | ▶ | $args->{format} ||= LOG_RFC3164; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args->{"format"} ||= 0
MC/DC0%0/1
$args->{"format"} ||= 0
$args->{"format"}
Truth table50%1/2
A
A= $args->{"format"}
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | return bless [ | ||||||||||||||||||||||||||||
| 47 | [], # loggers | ||||||||||||||||||||||||||||
| 48 | 2 | [@{ $args }{qw/ | |||||||||||||||||||||||||||
| 49 | proto hostname port facility severity sender name format | ||||||||||||||||||||||||||||
| 50 | /}], | ||||||||||||||||||||||||||||
| 51 | ], $class; | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 2 | ▶ | sub send { | ||||||||||||||||||||||||||
|
Subroutine
send: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | 2 | ▶ | my $severity = $_[3] || $_[0][_ARGS][_SEVERITY]; | ||||||||||||||||||||||||||
|
Condition66%2/3
$_[3] || $_[0][1][4]
MC/DC0%0/2
$_[3] || $_[0][1][4]
$_[3]
$_[0][1][4]
Truth table66%2/3
A || B
A= $_[3]B= $_[0][1][4]
| |||||||||||||||||||||||||||||
| 56 | 2 | ▶ | my $facility = $_[4] || $_[0][_ARGS][_FACILITY]; | ||||||||||||||||||||||||||
|
Condition66%2/3
$_[4] || $_[0][1][3]
MC/DC0%0/2
$_[4] || $_[0][1][3]
$_[4]
$_[0][1][3]
Truth table66%2/3
A || B
A= $_[4]B= $_[0][1][3]
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 2 | my $logger = $_[0][_LOGGERS][$facility][$severity]; | |||||||||||||||||||||||||||
| 59 | 2 | ▶ | if (!$logger) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 2 | my @args = @{ $_[0][_ARGS] }; | |||||||||||||||||||||||||||
| 61 | 2 | $args[_FACILITY] = $facility; | |||||||||||||||||||||||||||
| 62 | 2 | $args[_SEVERITY] = $severity; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 2 | my $format = pop(@args); | |||||||||||||||||||||||||||
| 65 | 2 | $logger = $_[0][_LOGGERS][$facility][$severity] = Log::Syslog::Fast->new(@args); | |||||||||||||||||||||||||||
| 66 | 2 | $logger->set_format($format); | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 2 | ▶ | return $logger->send($_[1], $_[2] || time); | ||||||||||||||||||||||||||
|
Condition100%2/2
$_[2] || time
MC/DC100%1/1
$_[2] || time
$_[2]
Truth table100%2/2
A
A= $_[2]
| |||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 2 | 1; | |||||||||||||||||||||||||||
| 73 | __END__ | ||||||||||||||||||||||||||||