blib/lib/Log/Log4perl/Layout/Syslog.pm

filter: Statementstmt 85.7% 18 / 21 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 84.8% 28 / 33 CC 3 SCAR 7.8
CC
3
Cov
80%
new
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
↑ Summary
1 package Log::Log4perl::Layout::Syslog;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =encoding utf8
10  
11 =head1 NAME
12  
13 Log::Log4perl::Layout::Syslog - Layout in Syslog format
14  
15 =head1 VERSION
16  
17 Version 0.03
18  
19 =cut
20  
21 1 our $VERSION = '0.03';
22  
23 =head1 SYNOPSIS
24  
25 This format is useful with the Log::Dispatch::Syslog class.
26 Add this to your configuration file:
27  
28 log4perl.appender.A1=Log::Dispatch::Syslog
29 log4perl.appender.A1.Filter=RangeAll
30 log4perl.appender.A1.ident=bandsman
31 log4perl.appender.A1.layout=Log::Log4perl::Layout::Syslog
32  
33 Much of the actual formatting is done by the Sys::Syslog code called
34 from Log::Dispatch::Syslog,
35 however you can't use Log::Log4perl::Layout::NoopLayout
36 since that doesn't insert the ident data that's needed by systems such as
37 flutentd.
38  
39 =cut
40  
41 =head2 new
42  
43 use Log::Log4perl::Layout::Syslog;
44 my $layout = Log::Log4perl::Layout::Syslog->new();
45  
46 =cut
47  
48 1 ▶sub new {
Subroutine new: called CC=3 SCAR=14.2
Pod documented
49 1 my $class = shift;
50  
51 1 ▶ if(!defined($class)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $class) { } 0 1 1
elsif (builtin::blessed($class)) { } 0 1 1
52 # Using Log::Log4perl::Layout::Syslog->new(), not Log::Log4perl::Layout::Syslog::new()
53 # carp(__PACKAGE__, ' use ->new() not ::new() to instantiate');
54 # return;
55  
56 # FIXME: this only works when no arguments are given
57 0 $class = __PACKAGE__;
58 } elsif(Scalar::Util::blessed($class)) {
59 # If $class is an object, clone it with new arguments
60 # return bless { %{$class}, %args }, ref($class);
61 0 return bless { %{$class} }, ref($class);
62 }
63  
64 # Return the blessed object
65 1 return bless {
66 info_needed => {},
67 stack => [],
68 }, $class;
69 }
70  
71 =head2 render
72  
73 Render a message in the correct format.
74  
75 =cut
76  
77 1 ▶sub render {
Subroutine render: called CC=1 SCAR=0.0
Pod documented
78 # my($self, $message, $category, $priority, $caller_level) = @_;
79 1 my $message = $_[1];
80  
81 1 return "user: $message";
82 }
83  
84 =head1 AUTHOR
85  
86 Nigel Horne, C<< <njh at bandsman.co.uk> >>
87  
88 =head1 BUGS
89  
90 I can't work out how to get the ident given to
91 Log::Dispatch::Syslog's constructor,
92 so ident (facility in RFC3164 lingo) is always sent to
93 LOG_USER.
94  
95 =head1 SEE ALSO
96  
97 L<Log::Log4perl>
98 L<Log::Dispatch::Syslog>
99  
100 =head1 SUPPORT
101  
102 You can find documentation for this module with the perldoc command.
103  
104 perldoc Log-Log4perl-Layout-Syslog
105  
106 You can also look for information at:
107  
108 =over 4
109  
110 =item * RT: CPAN's request tracker
111  
112 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Log-Log4perl-Layout-Syslog>
113  
114 =item * AnnoCPAN: Annotated CPAN documentation
115  
116 L<http://annocpan.org/dist/Log-Log4perl-Layout-Syslog>
117  
118 =item * Search CPAN
119  
120 L<http://search.cpan.org/dist/Log-Log4perl-Layout-Syslog/>
121  
122 =back
123  
124 =head1 LICENSE AND COPYRIGHT
125  
126 Copyright 2017-2014 Nigel Horne.
127  
128 This program is released under the following licence: GPL2
129  
130 =cut
131  
132 1 1;
↑ Summary