Compare commits

..

No commits in common. "master" and "pristine-tar" have entirely different histories.

28 changed files with 1 additions and 605 deletions

View File

@ -1,7 +0,0 @@
Revision history for Log-Log4perl-Layout-GELF
0.02 2011-07-19 12:00
Fixed dependencies and test files
0.01 2011-07-19 08:00
First version, released on an unsuspecting world.

View File

@ -1,15 +0,0 @@
Changes
ignore.txt
lib/Log/Log4perl/Layout/GELF.pm
Makefile.PL
MANIFEST This list of files
README
README.md
t/00-init.t
t/01-log_to_graylog.t
t/02-log_to_screen.t
t/manifest.t
t/pod-coverage.t
t/pod.t
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)

View File

@ -1,44 +0,0 @@
{
"abstract" : "Log4perl for graylog2",
"author" : [
"Jason Pope <cowholio4@gmail.com>"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 6.59, CPAN::Meta::Converter version 2.112150",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "Log-Log4perl-Layout-GELF",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : 0
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : 0
}
},
"runtime" : {
"requires" : {
"IO::Compress::Gzip" : "2.00",
"JSON::XS" : "2.30",
"Log::Log4perl" : "1.33",
"Test::More" : 0
}
}
},
"release_status" : "stable",
"version" : "0.03"
}

View File

@ -1,25 +0,0 @@
---
abstract: 'Log4perl for graylog2'
author:
- 'Jason Pope <cowholio4@gmail.com>'
build_requires:
ExtUtils::MakeMaker: 0
configure_requires:
ExtUtils::MakeMaker: 0
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 6.59, CPAN::Meta::Converter version 2.112150'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: Log-Log4perl-Layout-GELF
no_index:
directory:
- t
- inc
requires:
IO::Compress::Gzip: 2.00
JSON::XS: 2.30
Log::Log4perl: 1.33
Test::More: 0
version: 0.03

View File

@ -1,23 +0,0 @@
use 5.006;
use strict;
use warnings;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Log::Log4perl::Layout::GELF',
AUTHOR => q{Jason Pope <cowholio4@gmail.com>},
VERSION_FROM => 'lib/Log/Log4perl/Layout/GELF.pm',
ABSTRACT_FROM => 'lib/Log/Log4perl/Layout/GELF.pm',
($ExtUtils::MakeMaker::VERSION >= 6.3002
? ('LICENSE'=> 'perl')
: ()),
PL_FILES => {},
PREREQ_PM => {
'Test::More' => '0',
'JSON::XS' => '2.30',
'IO::Compress::Gzip' => '2.00',
'Log::Log4perl' => '1.33'
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Log-Log4perl-Layout-GELF-*' },
);

55
README
View File

@ -1,55 +0,0 @@
Log-Log4perl-Layout-GELF
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 to get an idea of the module's 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, run the following commands:
perl Makefile.PL
make
make test
make install
SUPPORT AND DOCUMENTATION
After installing, you can find documentation for this module with the
perldoc command.
perldoc Log::Log4perl::Layout::GELF
You can also look for information at:
RT, CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Log-Log4perl-Layout-GELF
AnnoCPAN, Annotated CPAN documentation
http://annocpan.org/dist/Log-Log4perl-Layout-GELF
CPAN Ratings
http://cpanratings.perl.org/d/Log-Log4perl-Layout-GELF
Search CPAN
http://search.cpan.org/dist/Log-Log4perl-Layout-GELF/
LICENSE AND COPYRIGHT
Copyright (C) 2011 Jason Pope
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.

View File

@ -1,9 +0,0 @@
Log::Log4perl::Layout::GELF (Log4perl in graylog format)
========================================================================
## Summary
[Log4perl]("http://search.cpan.org/~mschilli/Log-Log4perl-1.33/lib/Log/Log4perl.pm")
is great. [Graylog]("http://graylog2.org/") is awesome. This layout when used with
Log::Log4perl::Appender::Socket allows you to log directly to graylog.

5
debian/changelog vendored
View File

@ -1,5 +0,0 @@
liblog-log4perl-layout-gelf-perl (0.03-1) unstable; urgency=low
* Initial Release.
-- Mario Fetka <mario.fetka@gmail.com> Fri, 16 Feb 2018 16:04:08 +0100

1
debian/compat vendored
View File

@ -1 +0,0 @@
9

16
debian/control vendored
View File

@ -1,16 +0,0 @@
Source: liblog-log4perl-layout-gelf-perl
Section: perl
Priority: optional
Maintainer: Mario Fetka <mario.fetka@gmail.com>
Build-Depends: debhelper (>= 9), libjson-xs-perl, libio-compress-perl, liblog-log4perl-perl, libtest-simple-perl
Build-Depends-Indep: perl
Standards-Version: 3.9.6
Homepage: https://metacpan.org/release/Log-Log4perl-Layout-GELF
Package: liblog-log4perl-layout-gelf-perl
Architecture: all
Depends: ${misc:Depends}, ${perl:Depends}
Description: Log4perl for graylog2
(no description was found)
.
This description was automagically extracted from the module by dh-make-perl.

36
debian/copyright vendored
View File

@ -1,36 +0,0 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: https://metacpan.org/release/Log-Log4perl-Layout-GELF
Upstream-Contact: Jason Pope <cowholio4@gmail.com>
Upstream-Name: Log-Log4perl-Layout-GELF
DISCLAIMER: This copyright info was automatically extracted
from the perl module. It may not be accurate, so you better
check the module sources in order to ensure the module for its
inclusion in Debian or for general legal information. Please,
if licensing information is incorrectly generated, file a bug
on dh-make-perl.
NOTE: Don't forget to remove this disclaimer once you are happy
with this file.
Files: *
Copyright: Jason Pope <cowholio4@gmail.com>
License: Artistic or GPL-1+
Files: debian/*
Copyright: 2018, Mario Fetka <mario.fetka@gmail.com>
License: Artistic or GPL-1+
License: Artistic
This program is free software; you can redistribute it and/or modify
it under the terms of the Artistic License, which comes with Perl.
.
On Debian systems, the complete text of the Artistic License can be
found in `/usr/share/common-licenses/Artistic'.
License: GPL-1+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
.
On Debian systems, the complete text of version 1 of the GNU General
Public License can be found in `/usr/share/common-licenses/GPL-1'.

View File

@ -1,2 +0,0 @@
README.md
README

View File

@ -1,46 +0,0 @@
diff -uNr liblog-log4perl-layout-gelf-perl/t/01-log_to_graylog.t liblog/t/01-log_to_graylog.t
--- liblog-log4perl-layout-gelf-perl/t/01-log_to_graylog.t 2018-02-16 16:07:18.220000000 +0100
+++ liblog/t/01-log_to_graylog.t 1970-01-01 01:00:00.000000000 +0100
@@ -1,42 +0,0 @@
-#!perl -T
-
-use strict;
-use warnings;
-
-use Test::More tests => 4;
-
-BEGIN { use_ok( 'Log::Log4perl::Layout::GELF' ); }
-BEGIN { use_ok( 'Log::Log4perl' ); }
-
-my $layout = Log::Log4perl::Layout::GELF->new();
-isa_ok($layout, "Log::Log4perl::Layout::GELF");
-
-can_ok($layout, ("render"));
-
-_init_logger();
-
-
-sub _init_logger
-{
-
- my %logger_conf = (
- 'log4perl.logger.test.screen' => "DEBUG, DEFAULT",
- 'log4perl.appender.DEFAULT' => "Log::Log4perl::Appender::Screen",
- 'log4perl.appender.DEFAULT.stderr' => "0",
- 'log4perl.appender.DEFAULT.layout' => "GELF",
- 'log4perl.logger.test.server' => "DEBUG, SERVER",
- 'log4perl.appender.SERVER' => "Log::Log4perl::Appender::Socket",
- 'log4perl.appender.SERVER.PeerAddr' => '10.211.1.94',
- 'log4perl.appender.SERVER.PeerPort' => "12201",
- 'log4perl.appender.SERVER.Proto' => "udp",
- 'log4perl.appender.SERVER.layout' => "GELF"
- );
-
- Log::Log4perl->init( \%logger_conf );
- my $LOGGER = Log::Log4perl->get_logger('test.server');
- $LOGGER->debug("debug test");
- $LOGGER->error("error test");
- $LOGGER->info("info test");
- $LOGGER->warn("warn test");
- $LOGGER->fatal("fatal test");
-}

View File

@ -1 +0,0 @@
no-net-test.patch

4
debian/rules vendored
View File

@ -1,4 +0,0 @@
#!/usr/bin/make -f
%:
dh $@

View File

@ -1 +0,0 @@
3.0 (quilt)

View File

@ -1,4 +0,0 @@
---
Archive: CPAN
Contact: Jason Pope <cowholio4@gmail.com>
Name: Log-Log4perl-Layout-GELF

2
debian/watch vendored
View File

@ -1,2 +0,0 @@
version=3
https://metacpan.org/release/Log-Log4perl-Layout-GELF .*/Log-Log4perl-Layout-GELF-v?(\d[\d.-]*)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$

View File

@ -1,12 +0,0 @@
blib*
Makefile
Makefile.old
Build
Build.bat
_build*
pm_to_blib*
*.tar.gz
.lwpcookies
cover_db
pod2htm*.tmp
Log-Log4perl-Layout-GELF-*

View File

@ -1,165 +0,0 @@
##################################################
package Log::Log4perl::Layout::GELF;
##################################################
use 5.006;
use strict;
use warnings;
use JSON::XS;
use IO::Compress::Gzip qw( gzip $GzipError );
use Log::Log4perl;
use base qw(Log::Log4perl::Layout::PatternLayout);
# We need to define our own cspecs
$Log::Log4perl::ALLOW_CODE_IN_CONFIG_FILE = 1;
=head1 NAME
Log::Log4perl::Layout::GELF - Log4perl for graylog2
=head1 VERSION
Version 0.03
=cut
our $VERSION = '0.03';
=head1 SYNOPSIS
Log4perl implementation of GELF. When used with
Log::Log4perl::Appender::Socket you can log directly
to a graylog2 server.
=cut
=head1 What is graylog?
Graylog is log management server that can be used to run analytics,
alerting, monitoring and perform powerful searches over your whole
log base. Need to debug a failing request? Just run a quick filter
search to find it and see what errors it produced. Want to see all
messages a certain API consumer is consuming in real time? Create
streams for every consumer and have them always only one click away.
=cut
=head1 Configuration Sample
Code snippet. Replace the ip with your graylog server.
use Log::Log4perl
my $logger_conf = {
'log4perl.logger.graylog' => "DEBUG, SERVER",
'log4perl.appender.SERVER' => "Log::Log4perl::Appender::Socket",
'log4perl.appender.SERVER.PeerAddr' => '10.211.1.94',
'log4perl.appender.SERVER.PeerPort' => "12201",
'log4perl.appender.SERVER.Proto' => "udp",
'log4perl.appender.SERVER.layout' => "GELF"
};
Log::Log4perl->init( $logger_conf );
my $LOGGER = Log::Log4perl->get_logger('graylog');
$LOGGER->debug("Debug log");
...
=cut
=head1 SUBROUTINES/METHODS
=head2 new
Can take most of options that Log::Log4perl::Layout::PatternLayout can.
Additional Options:
PlainText - outputs plaintext and not gzipped files.
=cut
sub new {
my $class = shift;
$class = ref ($class) || $class;
my $options = ref $_[0] eq "HASH" ? shift : {};
# Creating object to make changes easier
my $gelf_format = {
"version" => "1.0",
"host" => "%H",
"short_message" => "%m{chomp}",
"timestamp" => "%Z", # custom cspec
"level"=> "%Y", # custom cspec
"facility"=> "%M",
"file"=> "%F",
"line"=> "%L",
"_pid" => "%P",
};
# make a JSON string
my $conversion_pattern = encode_json($gelf_format);
$options->{ConversionPattern} = { value => $conversion_pattern } ;
# Since we are building on top of PatternLayout, we can define our own
# own patterns using a "cspec".
$options->{cspec} = {
'Z' => { value => sub {return time } },
'Y' => { value => \&_level_converter } ,
};
my $self = $class->SUPER::new($options);
# to help with debugging. you can skip the bzipping.
$self->{PlainText} = 0;
if(defined $options->{PlainText}->{value} ){
$self->{PlainText} = $options->{PlainText}->{value};
}
return $self;
}
# Maps over the syslog levels from Log4perl levels.
# Syslog Levels for Reference
# 0 Emergency: system is unusable
# 1 Alert: action must be taken immediately
# 2 Critical: critical conditions
# 3 Error: error conditions
# 4 Warning: warning conditions
# 5 Notice: normal but significant condition
# 6 Informational: informational messages
# 7 Debug: debug-level messages
sub _level_converter {
my ($layout, $message, $category, $priority, $caller_level) = @_;
# TODO Replace with a case statement
my $levels = {
"DEBUG" => 7,
"INFO" => 6,
"NOTICE"=> 5,
"WARN" => 4,
"ERROR" => 3,
"FATAL" => 2
};
return $levels->{$priority};
}
=head2 render
Wraps the Log::Log4perl::Layout::PatternLayout return value so we can
gzip the JSON string.
=cut
sub render {
my($self, $message, $category, $priority, $caller_level) = @_;
my $encoded_message = $self->SUPER::render($message, $category, $priority, $caller_level);
# makes debugging easier
if( defined $self->{PlainText} && $self->{PlainText} ){
return $encoded_message;
}
# Graylog2 servers require gzipped messesages.
my $gzipped_message;
gzip \$encoded_message => \$gzipped_message or die "gzip failed: $GzipError\n";
return $gzipped_message;
}
1;

View File

@ -0,0 +1 @@
e8278f2895fa4dfa50bdf1b874f8e555ffbd5d7a

View File

@ -1,13 +0,0 @@
#!perl -T
use strict;
use warnings;
use Test::More tests => 3;
BEGIN { use_ok( 'Log::Log4perl::Layout::GELF' ); }
my $layout = Log::Log4perl::Layout::GELF->new();
isa_ok($layout, "Log::Log4perl::Layout::GELF");
can_ok($layout, ("render"));

View File

@ -1,42 +0,0 @@
#!perl -T
use strict;
use warnings;
use Test::More tests => 4;
BEGIN { use_ok( 'Log::Log4perl::Layout::GELF' ); }
BEGIN { use_ok( 'Log::Log4perl' ); }
my $layout = Log::Log4perl::Layout::GELF->new();
isa_ok($layout, "Log::Log4perl::Layout::GELF");
can_ok($layout, ("render"));
_init_logger();
sub _init_logger
{
my %logger_conf = (
'log4perl.logger.test.screen' => "DEBUG, DEFAULT",
'log4perl.appender.DEFAULT' => "Log::Log4perl::Appender::Screen",
'log4perl.appender.DEFAULT.stderr' => "0",
'log4perl.appender.DEFAULT.layout' => "GELF",
'log4perl.logger.test.server' => "DEBUG, SERVER",
'log4perl.appender.SERVER' => "Log::Log4perl::Appender::Socket",
'log4perl.appender.SERVER.PeerAddr' => '10.211.1.94',
'log4perl.appender.SERVER.PeerPort' => "12201",
'log4perl.appender.SERVER.Proto' => "udp",
'log4perl.appender.SERVER.layout' => "GELF"
);
Log::Log4perl->init( \%logger_conf );
my $LOGGER = Log::Log4perl->get_logger('test.server');
$LOGGER->debug("debug test");
$LOGGER->error("error test");
$LOGGER->info("info test");
$LOGGER->warn("warn test");
$LOGGER->fatal("fatal test");
}

View File

@ -1,34 +0,0 @@
#!perl -T
use strict;
use warnings;
use Test::More tests => 2;
BEGIN { use_ok( 'Log::Log4perl::Layout::GELF' ); }
BEGIN { use_ok( 'Log::Log4perl' ); }
_init_logger();
sub _init_logger
{
my %logger_conf = (
'log4perl.logger.test.screen' => "DEBUG, DEFAULT",
'log4perl.appender.DEFAULT' => "Log::Log4perl::Appender::Screen",
'log4perl.appender.DEFAULT.stderr' => "0",
'log4perl.appender.DEFAULT.layout' => "GELF",
'log4perl.appender.DEFAULT.layout.PlainText' => "1",
);
Log::Log4perl->init( \%logger_conf );
my $LOGGER = Log::Log4perl->get_logger('test.screen');
$LOGGER->debug("debug test");
$LOGGER->error("error test");
$LOGGER->info("info test");
$LOGGER->warn("warn test");
$LOGGER->fatal("fatal test");
}

View File

@ -1,13 +0,0 @@
#!perl -T
use strict;
use warnings;
use Test::More;
unless ( $ENV{RELEASE_TESTING} ) {
plan( skip_all => "Author tests not required for installation" );
}
eval "use Test::CheckManifest 0.9";
plan skip_all => "Test::CheckManifest 0.9 required" if $@;
ok_manifest();

View File

@ -1,18 +0,0 @@
use strict;
use warnings;
use Test::More;
# Ensure a recent version of Test::Pod::Coverage
my $min_tpc = 1.08;
eval "use Test::Pod::Coverage $min_tpc";
plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
if $@;
# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
# but older versions don't recognize some common documentation styles
my $min_pc = 0.18;
eval "use Pod::Coverage $min_pc";
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
if $@;
all_pod_coverage_ok();

12
t/pod.t
View File

@ -1,12 +0,0 @@
#!perl -T
use strict;
use warnings;
use Test::More;
# Ensure a recent version of Test::Pod
my $min_tp = 1.22;
eval "use Test::Pod $min_tp";
plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
all_pod_files_ok();