Compare commits
No commits in common. "master" and "pristine-tar" have entirely different histories.
master
...
pristine-t
52
Changes
52
Changes
@ -1,52 +0,0 @@
|
|||||||
HISTORY
|
|
||||||
0.99 Original version; created by h2xs 1.22 with options
|
|
||||||
|
|
||||||
-A
|
|
||||||
-C
|
|
||||||
-X
|
|
||||||
-b5.6.1
|
|
||||||
-nLog::Dispatch::File::Rolling
|
|
||||||
--skip-exporter
|
|
||||||
-v0.99
|
|
||||||
|
|
||||||
1.00 Initial coding
|
|
||||||
|
|
||||||
1.01 Someone once said "Never feed them after midnight!"---Ok, let's
|
|
||||||
append: "Never submit any code after midnight..."
|
|
||||||
|
|
||||||
Now it is working, I also included 4 tests.
|
|
||||||
|
|
||||||
1.02 No code change, just updated Makefile.PL to include correct
|
|
||||||
author information and prerequisites.
|
|
||||||
|
|
||||||
1.03 Changed the syntax of the '$' format character because I noticed
|
|
||||||
some problems while making Log::Dispatch::File::Alerts. You need
|
|
||||||
to change your configuration!
|
|
||||||
|
|
||||||
1.04 Got a bug report where the file handle got closed in
|
|
||||||
mid-execution somehow. Added a additional check to re-open it
|
|
||||||
instead of writing to a closed handle.
|
|
||||||
|
|
||||||
1.05 Updated packaging for newer standards. No changes to the coding.
|
|
||||||
|
|
||||||
1.06 Fixed a subtle bug that prevented us from locking the logfile
|
|
||||||
after a fork if no PID was used in the filename.
|
|
||||||
|
|
||||||
Also disabled forced double opening of the logfile at startup.
|
|
||||||
It was in place because I didn't trust Log::Dispatch::File to
|
|
||||||
really open the file at the right moment.
|
|
||||||
|
|
||||||
Thanks to Peter Lobsinger for the patch. Please always wrap
|
|
||||||
non-standard Test::* modules in eval and make your testfile
|
|
||||||
clean up after itself... ;)
|
|
||||||
|
|
||||||
1.07 Fixed rt.cpan.org bug #89001. Seems Log::Dispatch::File changed
|
|
||||||
its initialization procedure---and we are inheriting from it.
|
|
||||||
|
|
||||||
1.08 Fixed dependency on Log::Dispatch::File. The change in 1.07 only
|
|
||||||
works with 2.37 or later. For older versions of
|
|
||||||
Log::Dispatch::File use 1.06.
|
|
||||||
|
|
||||||
1.09 Dependency change of 1.08 was missing from the Makefile.PL.
|
|
||||||
Oops.
|
|
||||||
|
|
16
MANIFEST
16
MANIFEST
@ -1,16 +0,0 @@
|
|||||||
Makefile.PL
|
|
||||||
MANIFEST
|
|
||||||
README
|
|
||||||
Changes
|
|
||||||
lib/Log/Dispatch/File/Rolling.pm
|
|
||||||
t/1.t
|
|
||||||
t/2.t
|
|
||||||
t/3.t
|
|
||||||
t/4.t
|
|
||||||
t/5.t
|
|
||||||
t/6.t
|
|
||||||
META.yml
|
|
||||||
t/7testpod.t
|
|
||||||
t/8coverage.t
|
|
||||||
t/9reopenfh.t
|
|
||||||
META.json Module JSON meta-data (added by MakeMaker)
|
|
42
META.json
42
META.json
@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"abstract" : "Object for logging to date/time/pid stamped files",
|
|
||||||
"author" : [
|
|
||||||
"M. Jacob <jacob@j-e-b.net>"
|
|
||||||
],
|
|
||||||
"dynamic_config" : 1,
|
|
||||||
"generated_by" : "ExtUtils::MakeMaker version 6.86, CPAN::Meta::Converter version 2.120351",
|
|
||||||
"license" : [
|
|
||||||
"perl_5"
|
|
||||||
],
|
|
||||||
"meta-spec" : {
|
|
||||||
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
|
|
||||||
"version" : "2"
|
|
||||||
},
|
|
||||||
"name" : "Log-Dispatch-File-Rolling",
|
|
||||||
"no_index" : {
|
|
||||||
"directory" : [
|
|
||||||
"t",
|
|
||||||
"inc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"prereqs" : {
|
|
||||||
"build" : {
|
|
||||||
"requires" : {
|
|
||||||
"ExtUtils::MakeMaker" : "0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"configure" : {
|
|
||||||
"requires" : {
|
|
||||||
"ExtUtils::MakeMaker" : "0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"runtime" : {
|
|
||||||
"requires" : {
|
|
||||||
"Log::Dispatch" : "2.37",
|
|
||||||
"Log::Log4perl" : "0.32"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"release_status" : "stable",
|
|
||||||
"version" : "1.09"
|
|
||||||
}
|
|
23
META.yml
23
META.yml
@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
abstract: 'Object for logging to date/time/pid stamped files'
|
|
||||||
author:
|
|
||||||
- 'M. Jacob <jacob@j-e-b.net>'
|
|
||||||
build_requires:
|
|
||||||
ExtUtils::MakeMaker: 0
|
|
||||||
configure_requires:
|
|
||||||
ExtUtils::MakeMaker: 0
|
|
||||||
dynamic_config: 1
|
|
||||||
generated_by: 'ExtUtils::MakeMaker version 6.86, CPAN::Meta::Converter version 2.120351'
|
|
||||||
license: perl
|
|
||||||
meta-spec:
|
|
||||||
url: http://module-build.sourceforge.net/META-spec-v1.4.html
|
|
||||||
version: 1.4
|
|
||||||
name: Log-Dispatch-File-Rolling
|
|
||||||
no_index:
|
|
||||||
directory:
|
|
||||||
- t
|
|
||||||
- inc
|
|
||||||
requires:
|
|
||||||
Log::Dispatch: 2.37
|
|
||||||
Log::Log4perl: 0.32
|
|
||||||
version: 1.09
|
|
25
Makefile.PL
25
Makefile.PL
@ -1,25 +0,0 @@
|
|||||||
use 5.006001;
|
|
||||||
use ExtUtils::MakeMaker;
|
|
||||||
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
|
|
||||||
# the contents of the Makefile that is written.
|
|
||||||
WriteMakefile(
|
|
||||||
'NAME' => 'Log::Dispatch::File::Rolling',
|
|
||||||
'VERSION_FROM' => 'lib/Log/Dispatch/File/Rolling.pm', # finds $VERSION
|
|
||||||
'PREREQ_PM' => {
|
|
||||||
'Log::Log4perl' => '0.32',
|
|
||||||
'Log::Dispatch' => '2.37',
|
|
||||||
# 'Pod::Readme' => '0.05', # only needed for 'make dist'
|
|
||||||
},
|
|
||||||
($] >= 5.005 ? ( ## Add these new keywords supported since 5.005
|
|
||||||
ABSTRACT_FROM => 'lib/Log/Dispatch/File/Rolling.pm', # retrieve abstract from module
|
|
||||||
AUTHOR => 'M. Jacob <jacob@j-e-b.net>') : (),
|
|
||||||
LICENSE => 'perl',
|
|
||||||
depend => {
|
|
||||||
create_distdir => 'Changes',
|
|
||||||
Changes => 'lib/Log/Dispatch/File/Rolling.pm'."\n\t".q[$(FULLPERLRUN) -MPod::Readme -e 'Pod::Readme->new( readme_type => "changes" )->parse_from_file( "lib/Log/Dispatch/File/Rolling.pm", "Changes" )']."\n\n",
|
|
||||||
},
|
|
||||||
realclean => {
|
|
||||||
FILES => "Changes"
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
79
README
79
README
@ -1,79 +0,0 @@
|
|||||||
Log/Dispatch/File/Rolling version 1.09
|
|
||||||
======================================
|
|
||||||
|
|
||||||
--------
|
|
||||||
Abstract
|
|
||||||
--------
|
|
||||||
|
|
||||||
This module subclasses Log::Dispatch::File for logging to date/time
|
|
||||||
stamped files. It uses flock to ensure being safe in a multitasking
|
|
||||||
environment. It recognizes a fork() and will reopen the logfile, if
|
|
||||||
configured so even with a process specific filename.
|
|
||||||
|
|
||||||
------------
|
|
||||||
Requirements
|
|
||||||
------------
|
|
||||||
|
|
||||||
This module requires Log::Dispatch::File, included in the Log::Dispatch
|
|
||||||
distribution and Log::Log4perl::DateFormat, included in the
|
|
||||||
Log::Log4perl distribution. It has only be tested with the versions as
|
|
||||||
stated in Makefile.PL, if you find it works with earlier versions, too,
|
|
||||||
please send me a email. Thank you.
|
|
||||||
|
|
||||||
------------------
|
|
||||||
Basic Installation
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Log::Dispatch::File::Rolling may be installed through the CPAN shell in
|
|
||||||
the usual manner:
|
|
||||||
|
|
||||||
# perl -MCPAN -e 'install Log::Dispatch::File::Rolling'
|
|
||||||
|
|
||||||
You can also read this README from the CPAN shell:
|
|
||||||
|
|
||||||
# perl -MCPAN -e shell
|
|
||||||
cpan> readme Log::Dispatch::File::Rolling
|
|
||||||
|
|
||||||
And you can install the component from the CPAN prompt as well:
|
|
||||||
|
|
||||||
cpan> install Log::Dispatch::File::Rolling
|
|
||||||
|
|
||||||
-------------------
|
|
||||||
Manual Installation
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
Log::Dispatch::File::Rolling can also be installed manually. The latest
|
|
||||||
CPAN version can be found at <http://www.cpan.org/modules/by-
|
|
||||||
authors/id/J/JA/JACOB/> or in a similarly named directory at your
|
|
||||||
favorite CPAN mirror.
|
|
||||||
|
|
||||||
Downloading and unpacking the distribution are left as exercises for the
|
|
||||||
reader. To build and test it:
|
|
||||||
|
|
||||||
perl Makefile.PL
|
|
||||||
make test
|
|
||||||
|
|
||||||
When you're ready to install the component:
|
|
||||||
|
|
||||||
make install
|
|
||||||
|
|
||||||
It should now be ready to use.
|
|
||||||
|
|
||||||
On Win32 systems, replace "make" in the above commands with "nmake". The
|
|
||||||
nmake utility can be downloaded from
|
|
||||||
http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-
|
|
||||||
US/Nmake15.exe
|
|
||||||
|
|
||||||
---------------------
|
|
||||||
COPYRIGHT AND LICENCE
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
Copyright (C) 2003, 2004, 2007, 2010, 2013 M. Jacob <jacob@j-e-b.net>
|
|
||||||
|
|
||||||
Based on:
|
|
||||||
Log::Dispatch::File::Stamped by Eric Cholet <cholet@logilune.com>
|
|
||||||
Log::Dispatch::FileRotate by Mark Pfeiffer, <markpf@mlp-consulting.com.au>
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or modify it
|
|
||||||
under the same terms as Perl itself.
|
|
||||||
|
|
19
debian/changelog
vendored
19
debian/changelog
vendored
@ -1,19 +0,0 @@
|
|||||||
liblog-dispatch-file-rolling-perl (1.09-1) UNRELEASED; urgency=medium
|
|
||||||
|
|
||||||
* Non-maintainer upload.
|
|
||||||
* New Release
|
|
||||||
* Rebuild
|
|
||||||
|
|
||||||
-- Mario Fetka <mario.fetka@gmail.com> Mon, 16 Jan 2017 14:39:46 +0100
|
|
||||||
|
|
||||||
liblog-dispatch-file-rolling-perl (0.16-2) unstable; urgency=medium
|
|
||||||
|
|
||||||
* Fixed metadata
|
|
||||||
|
|
||||||
-- Marco Pessotto <melmothx@gmail.com> Sun, 21 Feb 2016 13:03:43 +0100
|
|
||||||
|
|
||||||
liblog-dispatch-file-rolling-perl (0.16-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* Initial Release.
|
|
||||||
|
|
||||||
-- Marco Pessotto <melmothx@gmail.com> Sun, 21 Feb 2016 12:59:24 +0100
|
|
1
debian/compat
vendored
1
debian/compat
vendored
@ -1 +0,0 @@
|
|||||||
9
|
|
19
debian/control
vendored
19
debian/control
vendored
@ -1,19 +0,0 @@
|
|||||||
Source: liblog-dispatch-file-rolling-perl
|
|
||||||
Section: perl
|
|
||||||
Priority: optional
|
|
||||||
Maintainer: Marco Pessotto <melmothx@gmail.com>
|
|
||||||
Build-Depends: debhelper (>= 9)
|
|
||||||
Build-Depends-Indep: liblog-dispatch-perl (>= 2.30),
|
|
||||||
liblog-log4perl-perl (>= 0.28),
|
|
||||||
perl
|
|
||||||
Standards-Version: 3.9.6
|
|
||||||
Homepage: https://metacpan.org/release/Log-Dispatch-File-rolling
|
|
||||||
|
|
||||||
Package: liblog-dispatch-file-rolling-perl
|
|
||||||
Architecture: all
|
|
||||||
Depends: ${misc:Depends}, ${perl:Depends},
|
|
||||||
liblog-dispatch-perl (>= 2.30),
|
|
||||||
liblog-log4perl-perl (>= 0.28)
|
|
||||||
Description: Logging to date/time rolling files
|
|
||||||
Log::Dispatch::File::rolling subclasses Log::Dispatch::File for logging to
|
|
||||||
date/time rolling files, respecting all its configuration options.
|
|
28
debian/copyright
vendored
28
debian/copyright
vendored
@ -1,28 +0,0 @@
|
|||||||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
|
||||||
Source: https://metacpan.org/release/Log-Dispatch-File-Stamped
|
|
||||||
Upstream-Contact: Eric Cholet <cholet@logilune.com>, Karen Etheridge <ether@cpan.org>
|
|
||||||
Upstream-Name: Log-Dispatch-File-Stamped
|
|
||||||
|
|
||||||
Files: *
|
|
||||||
Copyright: Eric Cholet <cholet@logilune.com>, Karen Etheridge <ether@cpan.org>
|
|
||||||
License: Artistic or GPL-1+
|
|
||||||
|
|
||||||
Files: debian/*
|
|
||||||
Copyright: 2016, Marco Pessotto <melmothx@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'.
|
|
@ -1,119 +0,0 @@
|
|||||||
From f5ff541806ee2f0c5d6c8623ac6a591a79556342 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Michael Schout <mschout@gkg.net>
|
|
||||||
Date: Mon, 14 Aug 2017 13:09:27 -0500
|
|
||||||
Subject: [PATCH] Update to work with Log::Dispatch v2.59 and later
|
|
||||||
|
|
||||||
See https://rt.cpan.org/Ticket/Display.html?id=120378
|
|
||||||
---
|
|
||||||
META.json | 2 +-
|
|
||||||
META.yml | 2 +-
|
|
||||||
Makefile.PL | 2 +-
|
|
||||||
lib/Log/Dispatch/File/Rolling.pm | 26 ++++++++++----------------
|
|
||||||
4 files changed, 13 insertions(+), 19 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/META.json b/META.json
|
|
||||||
index c17c800..194ee13 100644
|
|
||||||
--- a/META.json
|
|
||||||
+++ b/META.json
|
|
||||||
@@ -32,7 +32,7 @@
|
|
||||||
},
|
|
||||||
"runtime" : {
|
|
||||||
"requires" : {
|
|
||||||
- "Log::Dispatch" : "2.37",
|
|
||||||
+ "Log::Dispatch" : "2.59",
|
|
||||||
"Log::Log4perl" : "0.32"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/META.yml b/META.yml
|
|
||||||
index dd9b950..da355e1 100644
|
|
||||||
--- a/META.yml
|
|
||||||
+++ b/META.yml
|
|
||||||
@@ -18,6 +18,6 @@ no_index:
|
|
||||||
- t
|
|
||||||
- inc
|
|
||||||
requires:
|
|
||||||
- Log::Dispatch: 2.37
|
|
||||||
+ Log::Dispatch: 2.59
|
|
||||||
Log::Log4perl: 0.32
|
|
||||||
version: 1.09
|
|
||||||
diff --git a/Makefile.PL b/Makefile.PL
|
|
||||||
index add5084..c3bfaeb 100755
|
|
||||||
--- a/Makefile.PL
|
|
||||||
+++ b/Makefile.PL
|
|
||||||
@@ -7,7 +7,7 @@ WriteMakefile(
|
|
||||||
'VERSION_FROM' => 'lib/Log/Dispatch/File/Rolling.pm', # finds $VERSION
|
|
||||||
'PREREQ_PM' => {
|
|
||||||
'Log::Log4perl' => '0.32',
|
|
||||||
- 'Log::Dispatch' => '2.37',
|
|
||||||
+ 'Log::Dispatch' => '2.59',
|
|
||||||
# 'Pod::Readme' => '0.05', # only needed for 'make dist'
|
|
||||||
},
|
|
||||||
($] >= 5.005 ? ( ## Add these new keywords supported since 5.005
|
|
||||||
diff --git a/lib/Log/Dispatch/File/Rolling.pm b/lib/Log/Dispatch/File/Rolling.pm
|
|
||||||
index 2928c1e..3e5fbbc 100755
|
|
||||||
--- a/lib/Log/Dispatch/File/Rolling.pm
|
|
||||||
+++ b/lib/Log/Dispatch/File/Rolling.pm
|
|
||||||
@@ -5,7 +5,7 @@ use 5.006001;
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
|
|
||||||
-use Log::Dispatch::File '2.37';
|
|
||||||
+use Log::Dispatch::File '2.59';
|
|
||||||
use Log::Log4perl::DateFormat;
|
|
||||||
use Fcntl ':flock'; # import LOCK_* constants
|
|
||||||
|
|
||||||
@@ -30,42 +30,36 @@ BEGIN { # borrowed from Log::Log4perl::Layout::PatternLayout, Thanks!
|
|
||||||
|
|
||||||
# Preloaded methods go here.
|
|
||||||
|
|
||||||
-sub new {
|
|
||||||
- my $proto = shift;
|
|
||||||
- my $class = ref $proto || $proto;
|
|
||||||
+sub _basic_init {
|
|
||||||
+ my $self = shift;
|
|
||||||
|
|
||||||
my %p = @_;
|
|
||||||
|
|
||||||
- my $self = bless {}, $class;
|
|
||||||
-
|
|
||||||
# only append mode is supported
|
|
||||||
- $p{mode} = 'append';
|
|
||||||
+ $self->{mode} = '>>';
|
|
||||||
|
|
||||||
- # base class initialization
|
|
||||||
- $self->_basic_init(%p);
|
|
||||||
+ $self->{rolling_fh_pid} = $$;
|
|
||||||
|
|
||||||
# split pathname into path, basename, extension
|
|
||||||
- if ($p{filename} =~ /^(.*)\%d\{([^\}]*)\}(.*)$/) {
|
|
||||||
+ if ($self->{filename} =~ /^(.*)\%d\{([^\}]*)\}(.*)$/) {
|
|
||||||
$self->{rolling_filename_prefix} = $1;
|
|
||||||
$self->{rolling_filename_postfix} = $3;
|
|
||||||
$self->{rolling_filename_format} = Log::Log4perl::DateFormat->new($2);
|
|
||||||
$self->{filename} = $self->_createFilename();
|
|
||||||
- } elsif ($p{filename} =~ /^(.*)(\.[^\.]+)$/) {
|
|
||||||
+ } elsif ($self->{filename} =~ /^(.*)(\.[^\.]+)$/) {
|
|
||||||
$self->{rolling_filename_prefix} = $1;
|
|
||||||
$self->{rolling_filename_postfix} = $2;
|
|
||||||
$self->{rolling_filename_format} = Log::Log4perl::DateFormat->new('-yyyy-MM-dd');
|
|
||||||
$self->{filename} = $self->_createFilename();
|
|
||||||
} else {
|
|
||||||
- $self->{rolling_filename_prefix} = $p{filename};
|
|
||||||
+ $self->{rolling_filename_prefix} = $self->{filename};
|
|
||||||
$self->{rolling_filename_postfix} = '';
|
|
||||||
$self->{rolling_filename_format} = Log::Log4perl::DateFormat->new('.yyyy-MM-dd');
|
|
||||||
$self->{filename} = $self->_createFilename();
|
|
||||||
}
|
|
||||||
|
|
||||||
- $self->{rolling_fh_pid} = $$;
|
|
||||||
- $self->_make_handle();
|
|
||||||
-
|
|
||||||
- return $self;
|
|
||||||
+ # base class initialization
|
|
||||||
+ $self->SUPER::_basic_init(%p);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub log_message { # parts borrowed from Log::Dispatch::FileRotate, Thanks!
|
|
||||||
--
|
|
||||||
2.12.2
|
|
||||||
|
|
1
debian/patches/series
vendored
1
debian/patches/series
vendored
@ -1 +0,0 @@
|
|||||||
0001-Update-to-work-with-Log-Dispatch-v2.59-and-later.patch
|
|
4
debian/rules
vendored
4
debian/rules
vendored
@ -1,4 +0,0 @@
|
|||||||
#!/usr/bin/make -f
|
|
||||||
|
|
||||||
%:
|
|
||||||
dh $@
|
|
1
debian/source/format
vendored
1
debian/source/format
vendored
@ -1 +0,0 @@
|
|||||||
3.0 (quilt)
|
|
8
debian/upstream/metadata
vendored
8
debian/upstream/metadata
vendored
@ -1,8 +0,0 @@
|
|||||||
---
|
|
||||||
Archive: CPAN
|
|
||||||
Bug-Database: https://rt.cpan.org/Public/Dist/Display.html?Name=Log-Dispatch-File-Rolling
|
|
||||||
Bug-Submit: bug-Log-Dispatch-File-Rolling@rt.cpan.org
|
|
||||||
Contact: Eric Cholet <cholet@logilune.com>, Karen Etheridge <ether@cpan.org>
|
|
||||||
Name: Log-Dispatch-File-Rolling
|
|
||||||
Repository: https://github.com/karenetheridge/Log-Dispatch-File-Rolling.git
|
|
||||||
Repository-Browse: https://github.com/karenetheridge/Log-Dispatch-File-Rolling
|
|
2
debian/watch
vendored
2
debian/watch
vendored
@ -1,2 +0,0 @@
|
|||||||
version=3
|
|
||||||
https://metacpan.org/release/Log-Dispatch-File-Rolling .*/Log-Dispatch-File-Rolling-v?(\d[\d.-]*)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$
|
|
@ -1,328 +0,0 @@
|
|||||||
## no critic
|
|
||||||
package Log::Dispatch::File::Rolling;
|
|
||||||
|
|
||||||
use 5.006001;
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
|
|
||||||
use Log::Dispatch::File '2.37';
|
|
||||||
use Log::Log4perl::DateFormat;
|
|
||||||
use Fcntl ':flock'; # import LOCK_* constants
|
|
||||||
|
|
||||||
our @ISA = qw(Log::Dispatch::File);
|
|
||||||
|
|
||||||
our $VERSION = '1.09';
|
|
||||||
|
|
||||||
our $TIME_HIRES_AVAILABLE = undef;
|
|
||||||
|
|
||||||
BEGIN { # borrowed from Log::Log4perl::Layout::PatternLayout, Thanks!
|
|
||||||
# Check if we've got Time::HiRes. If not, don't make a big fuss,
|
|
||||||
# just set a flag so we know later on that we can't have fine-grained
|
|
||||||
# time stamps
|
|
||||||
|
|
||||||
eval { require Time::HiRes; };
|
|
||||||
if ($@) {
|
|
||||||
$TIME_HIRES_AVAILABLE = 0;
|
|
||||||
} else {
|
|
||||||
$TIME_HIRES_AVAILABLE = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Preloaded methods go here.
|
|
||||||
|
|
||||||
sub new {
|
|
||||||
my $proto = shift;
|
|
||||||
my $class = ref $proto || $proto;
|
|
||||||
|
|
||||||
my %p = @_;
|
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
|
||||||
|
|
||||||
# only append mode is supported
|
|
||||||
$p{mode} = 'append';
|
|
||||||
|
|
||||||
# base class initialization
|
|
||||||
$self->_basic_init(%p);
|
|
||||||
|
|
||||||
# split pathname into path, basename, extension
|
|
||||||
if ($p{filename} =~ /^(.*)\%d\{([^\}]*)\}(.*)$/) {
|
|
||||||
$self->{rolling_filename_prefix} = $1;
|
|
||||||
$self->{rolling_filename_postfix} = $3;
|
|
||||||
$self->{rolling_filename_format} = Log::Log4perl::DateFormat->new($2);
|
|
||||||
$self->{filename} = $self->_createFilename();
|
|
||||||
} elsif ($p{filename} =~ /^(.*)(\.[^\.]+)$/) {
|
|
||||||
$self->{rolling_filename_prefix} = $1;
|
|
||||||
$self->{rolling_filename_postfix} = $2;
|
|
||||||
$self->{rolling_filename_format} = Log::Log4perl::DateFormat->new('-yyyy-MM-dd');
|
|
||||||
$self->{filename} = $self->_createFilename();
|
|
||||||
} else {
|
|
||||||
$self->{rolling_filename_prefix} = $p{filename};
|
|
||||||
$self->{rolling_filename_postfix} = '';
|
|
||||||
$self->{rolling_filename_format} = Log::Log4perl::DateFormat->new('.yyyy-MM-dd');
|
|
||||||
$self->{filename} = $self->_createFilename();
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{rolling_fh_pid} = $$;
|
|
||||||
$self->_make_handle();
|
|
||||||
|
|
||||||
return $self;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub log_message { # parts borrowed from Log::Dispatch::FileRotate, Thanks!
|
|
||||||
my $self = shift;
|
|
||||||
my %p = @_;
|
|
||||||
|
|
||||||
my $filename = $self->_createFilename();
|
|
||||||
if ($filename ne $self->{filename}) {
|
|
||||||
$self->{filename} = $filename;
|
|
||||||
$self->{rolling_fh_pid} = 'x'; # force reopen
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $self->{close} ) {
|
|
||||||
$self->_open_file;
|
|
||||||
$self->_lock();
|
|
||||||
my $fh = $self->{fh};
|
|
||||||
print $fh $p{message};
|
|
||||||
$self->_unlock();
|
|
||||||
close($fh);
|
|
||||||
$self->{fh} = undef;
|
|
||||||
} elsif (defined $self->{fh} and ($self->{rolling_fh_pid}||'') eq $$ and defined fileno $self->{fh}) { # flock won't work after a fork()
|
|
||||||
my $inode = (stat($self->{fh}))[1]; # get real inode
|
|
||||||
my $finode = (stat($self->{filename}))[1]; # Stat the name for comparision
|
|
||||||
if(!defined($finode) || $inode != $finode) { # Oops someone moved things on us. So just reopen our log
|
|
||||||
$self->_open_file;
|
|
||||||
}
|
|
||||||
$self->_lock();
|
|
||||||
my $fh = $self->{fh};
|
|
||||||
print $fh $p{message};
|
|
||||||
$self->_unlock();
|
|
||||||
} else {
|
|
||||||
$self->{rolling_fh_pid} = $$;
|
|
||||||
$self->_open_file;
|
|
||||||
$self->_lock();
|
|
||||||
my $fh = $self->{fh};
|
|
||||||
print $fh $p{message};
|
|
||||||
$self->_unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub _lock { # borrowed from Log::Dispatch::FileRotate, Thanks!
|
|
||||||
my $self = shift;
|
|
||||||
flock($self->{fh},LOCK_EX);
|
|
||||||
# Make sure we are at the EOF
|
|
||||||
seek($self->{fh}, 0, 2);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub _unlock { # borrowed from Log::Dispatch::FileRotate, Thanks!
|
|
||||||
my $self = shift;
|
|
||||||
flock($self->{fh},LOCK_UN);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub _current_time { # borrowed from Log::Log4perl::Layout::PatternLayout, Thanks!
|
|
||||||
# Return secs and optionally msecs if we have Time::HiRes
|
|
||||||
if($TIME_HIRES_AVAILABLE) {
|
|
||||||
return (Time::HiRes::gettimeofday());
|
|
||||||
} else {
|
|
||||||
return (time(), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub _createFilename {
|
|
||||||
my $self = shift;
|
|
||||||
return $self->{rolling_filename_prefix}
|
|
||||||
. $self->_format()
|
|
||||||
. $self->{rolling_filename_postfix};
|
|
||||||
}
|
|
||||||
|
|
||||||
sub _format {
|
|
||||||
my $self = shift;
|
|
||||||
my $result = $self->{rolling_filename_format}->format($self->_current_time());
|
|
||||||
$result =~ s/(\$+)/sprintf('%0'.length($1).'.'.length($1).'u', $$)/eg;
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
|
||||||
__END__
|
|
||||||
|
|
||||||
=for changes stop
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
Log::Dispatch::File::Rolling - Object for logging to date/time/pid
|
|
||||||
stamped files
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
use Log::Dispatch::File::Rolling;
|
|
||||||
|
|
||||||
my $file = Log::Dispatch::File::Rolling->new(
|
|
||||||
name => 'file1',
|
|
||||||
min_level => 'info',
|
|
||||||
filename => 'Somefile%d{yyyyMMdd}.log',
|
|
||||||
mode => 'append' );
|
|
||||||
|
|
||||||
$file->log( level => 'emerg',
|
|
||||||
message => "I've fallen and I can't get up\n" );
|
|
||||||
|
|
||||||
=head1 ABSTRACT
|
|
||||||
|
|
||||||
This module provides an object for logging to files under the
|
|
||||||
Log::Dispatch::* system.
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
This module subclasses Log::Dispatch::File for logging to date/time
|
|
||||||
stamped files. See L<Log::Dispatch::File> for instructions on usage.
|
|
||||||
This module differs only on the following three points:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item fork()-safe
|
|
||||||
|
|
||||||
This module will close and re-open the logfile after a fork.
|
|
||||||
|
|
||||||
=item multitasking-safe
|
|
||||||
|
|
||||||
This module uses flock() to lock the file while writing to it.
|
|
||||||
|
|
||||||
=item stamped filenames
|
|
||||||
|
|
||||||
This module supports a special tag in the filename that will expand to
|
|
||||||
the current date/time/pid.
|
|
||||||
|
|
||||||
It is the same tag Log::Log4perl::Layout::PatternLayout uses, see
|
|
||||||
L<Log::Log4perl::Layout::PatternLayout>, chapter "Fine-tune the date".
|
|
||||||
In short: Include a "%d{...}" in the filename where "..." is a format
|
|
||||||
string according to the SimpleDateFormat in the Java World
|
|
||||||
(http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html).
|
|
||||||
See also L<Log::Log4perl::DateFormat> for information about further
|
|
||||||
restrictions.
|
|
||||||
|
|
||||||
In addition to the format provided by Log::Log4perl::DateFormat this
|
|
||||||
module also supports '$' for inserting the PID. Repeat the character to
|
|
||||||
define how many character wide the field should be. This should not be
|
|
||||||
needed regularly as this module also supports logfile sharing between
|
|
||||||
processes, but if you've got a high load on your logfile or a system
|
|
||||||
that doesn't support flock()...
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=head1 METHODS
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
=item new()
|
|
||||||
|
|
||||||
See L<Log::Dispatch::File> and chapter DESCRIPTION above.
|
|
||||||
|
|
||||||
=item log_message()
|
|
||||||
|
|
||||||
See L<Log::Dispatch::File> and chapter DESCRIPTION above.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=for changes continue
|
|
||||||
|
|
||||||
=head1 HISTORY
|
|
||||||
|
|
||||||
=over 8
|
|
||||||
|
|
||||||
=item 0.99
|
|
||||||
|
|
||||||
Original version; created by h2xs 1.22 with options
|
|
||||||
|
|
||||||
-A
|
|
||||||
-C
|
|
||||||
-X
|
|
||||||
-b5.6.1
|
|
||||||
-nLog::Dispatch::File::Rolling
|
|
||||||
--skip-exporter
|
|
||||||
-v0.99
|
|
||||||
|
|
||||||
=item 1.00
|
|
||||||
|
|
||||||
Initial coding
|
|
||||||
|
|
||||||
=item 1.01
|
|
||||||
|
|
||||||
Someone once said "Never feed them after midnight!"---Ok, let's append:
|
|
||||||
"Never submit any code after midnight..."
|
|
||||||
|
|
||||||
Now it is working, I also included 4 tests.
|
|
||||||
|
|
||||||
=item 1.02
|
|
||||||
|
|
||||||
No code change, just updated Makefile.PL to include correct author
|
|
||||||
information and prerequisites.
|
|
||||||
|
|
||||||
=item 1.03
|
|
||||||
|
|
||||||
Changed the syntax of the '$' format character because I noticed some
|
|
||||||
problems while making Log::Dispatch::File::Alerts. You need to change
|
|
||||||
your configuration!
|
|
||||||
|
|
||||||
=item 1.04
|
|
||||||
|
|
||||||
Got a bug report where the file handle got closed in mid-execution somehow.
|
|
||||||
Added a additional check to re-open it instead of writing to a closed
|
|
||||||
handle.
|
|
||||||
|
|
||||||
=item 1.05
|
|
||||||
|
|
||||||
Updated packaging for newer standards. No changes to the coding.
|
|
||||||
|
|
||||||
=item 1.06
|
|
||||||
|
|
||||||
Fixed a subtle bug that prevented us from locking the logfile after a fork if no
|
|
||||||
PID was used in the filename.
|
|
||||||
|
|
||||||
Also disabled forced double opening of the logfile at startup. It was in place
|
|
||||||
because I didn't trust L<Log::Dispatch::File> to really open the file at the
|
|
||||||
right moment.
|
|
||||||
|
|
||||||
Thanks to Peter Lobsinger for the patch. Please always wrap non-standard Test::*
|
|
||||||
modules in eval and make your testfile clean up after itself... ;)
|
|
||||||
|
|
||||||
=item 1.07
|
|
||||||
|
|
||||||
Fixed rt.cpan.org bug #89001. Seems L<Log::Dispatch::File> changed its
|
|
||||||
initialization procedure---and we are inheriting from it.
|
|
||||||
|
|
||||||
=item 1.08
|
|
||||||
|
|
||||||
Fixed dependency on L<Log::Dispatch::File>. The change in 1.07 only works with
|
|
||||||
2.37 or later. For older versions of L<Log::Dispatch::File> use 1.06.
|
|
||||||
|
|
||||||
=item 1.09
|
|
||||||
|
|
||||||
Dependency change of 1.08 was missing from the Makefile.PL. Oops.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=for changes stop
|
|
||||||
|
|
||||||
=head1 SEE ALSO
|
|
||||||
|
|
||||||
L<Log::Dispatch::File>, L<Log::Log4perl::Layout::PatternLayout>,
|
|
||||||
http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html,
|
|
||||||
L<Log::Log4perl::DateFormat>, 'perldoc -f flock', 'perldoc -f fork'.
|
|
||||||
|
|
||||||
=head1 AUTHOR
|
|
||||||
|
|
||||||
M. Jacob, E<lt>jacob@j-e-b.netE<gt>
|
|
||||||
|
|
||||||
=head1 COPYRIGHT AND LICENSE
|
|
||||||
|
|
||||||
Copyright (C) 2003, 2004, 2007, 2010, 2013 M. Jacob E<lt>jacob@j-e-b.netE<gt>
|
|
||||||
|
|
||||||
Based on:
|
|
||||||
|
|
||||||
Log::Dispatch::File::Stamped by Eric Cholet <cholet@logilune.com>
|
|
||||||
Log::Dispatch::FileRotate by Mark Pfeiffer, <markpf@mlp-consulting.com.au>
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or modify
|
|
||||||
it under the same terms as Perl itself.
|
|
||||||
|
|
||||||
=cut
|
|
BIN
liblog-dispatch-file-rolling-perl_1.09.orig.tar.gz.delta
Normal file
BIN
liblog-dispatch-file-rolling-perl_1.09.orig.tar.gz.delta
Normal file
Binary file not shown.
1
liblog-dispatch-file-rolling-perl_1.09.orig.tar.gz.id
Normal file
1
liblog-dispatch-file-rolling-perl_1.09.orig.tar.gz.id
Normal file
@ -0,0 +1 @@
|
|||||||
|
11150153d97b24dab0a424c0bb803bea15cc4cd1
|
17
t/1.t
17
t/1.t
@ -1,17 +0,0 @@
|
|||||||
# Before `make install' is performed this script should be runnable with
|
|
||||||
# `make test'. After `make install' it should work as `perl 1.t'
|
|
||||||
|
|
||||||
#########################
|
|
||||||
|
|
||||||
# change 'tests => 1' to 'tests => last_test_to_print';
|
|
||||||
|
|
||||||
use Test;
|
|
||||||
BEGIN { plan tests => 1 };
|
|
||||||
use Log::Dispatch::File::Rolling;
|
|
||||||
ok(1); # If we made it this far, we're ok.
|
|
||||||
|
|
||||||
#########################
|
|
||||||
|
|
||||||
# Insert your test code below, the Test::More module is use()ed here so read
|
|
||||||
# its man page ( perldoc Test::More ) for help writing this test script.
|
|
||||||
|
|
18
t/2.t
18
t/2.t
@ -1,18 +0,0 @@
|
|||||||
# Before `make install' is performed this script should be runnable with
|
|
||||||
# `make test'. After `make install' it should work as `perl 1.t'
|
|
||||||
|
|
||||||
#########################
|
|
||||||
|
|
||||||
# change 'tests => 1' to 'tests => last_test_to_print';
|
|
||||||
|
|
||||||
use Test;
|
|
||||||
BEGIN { plan tests => 1 };
|
|
||||||
use Log::Dispatch;
|
|
||||||
use Log::Dispatch::File::Rolling;
|
|
||||||
ok(1); # If we made it this far, we're ok.
|
|
||||||
|
|
||||||
#########################
|
|
||||||
|
|
||||||
# Insert your test code below, the Test::More module is use()ed here so read
|
|
||||||
# its man page ( perldoc Test::More ) for help writing this test script.
|
|
||||||
|
|
70
t/3.t
70
t/3.t
@ -1,70 +0,0 @@
|
|||||||
# Before `make install' is performed this script should be runnable with
|
|
||||||
# `make test'. After `make install' it should work as `perl 1.t'
|
|
||||||
|
|
||||||
#########################
|
|
||||||
|
|
||||||
# change 'tests => 1' to 'tests => last_test_to_print';
|
|
||||||
|
|
||||||
use Test;
|
|
||||||
BEGIN { plan tests => 8 };
|
|
||||||
use Log::Dispatch;
|
|
||||||
use Log::Dispatch::File::Rolling;
|
|
||||||
ok(1); # If we made it this far, we're ok.
|
|
||||||
|
|
||||||
#########################1
|
|
||||||
|
|
||||||
my $dispatcher = Log::Dispatch->new;
|
|
||||||
ok($dispatcher);
|
|
||||||
|
|
||||||
#########################2
|
|
||||||
|
|
||||||
my %params = (
|
|
||||||
name => 'file',
|
|
||||||
min_level => 'debug',
|
|
||||||
filename => 'logfile.txt',
|
|
||||||
);
|
|
||||||
|
|
||||||
my $Rolling = Log::Dispatch::File::Rolling->new(%params);
|
|
||||||
ok($Rolling);
|
|
||||||
|
|
||||||
#########################3
|
|
||||||
|
|
||||||
$dispatcher->add($Rolling);
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################4
|
|
||||||
|
|
||||||
my $message = 'logtest id ' . int(rand(9999));
|
|
||||||
|
|
||||||
$dispatcher->log( level => 'info', message => $message );
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################5
|
|
||||||
|
|
||||||
$dispatcher = $Rolling = undef;
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################6
|
|
||||||
|
|
||||||
my @logfiles = glob('logfile*.txt');
|
|
||||||
|
|
||||||
ok(scalar(@logfiles) == 1 or scalar(@logfiles) == 2);
|
|
||||||
|
|
||||||
#########################7
|
|
||||||
|
|
||||||
my $content = '';
|
|
||||||
|
|
||||||
foreach my $file (@logfiles) {
|
|
||||||
open F, '<', $file;
|
|
||||||
local $/ = undef;
|
|
||||||
$content .= <F>;
|
|
||||||
close F;
|
|
||||||
unlink $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
ok($content =~ /$message/);
|
|
||||||
|
|
||||||
#########################8
|
|
70
t/4.t
70
t/4.t
@ -1,70 +0,0 @@
|
|||||||
# Before `make install' is performed this script should be runnable with
|
|
||||||
# `make test'. After `make install' it should work as `perl 1.t'
|
|
||||||
|
|
||||||
#########################
|
|
||||||
|
|
||||||
# change 'tests => 1' to 'tests => last_test_to_print';
|
|
||||||
|
|
||||||
use Test;
|
|
||||||
BEGIN { plan tests => 8 };
|
|
||||||
use Log::Dispatch;
|
|
||||||
use Log::Dispatch::File::Rolling;
|
|
||||||
ok(1); # If we made it this far, we're ok.
|
|
||||||
|
|
||||||
#########################1
|
|
||||||
|
|
||||||
my $dispatcher = Log::Dispatch->new;
|
|
||||||
ok($dispatcher);
|
|
||||||
|
|
||||||
#########################2
|
|
||||||
|
|
||||||
my %params = (
|
|
||||||
name => 'file',
|
|
||||||
min_level => 'debug',
|
|
||||||
filename => 'logfile%d{$$}.txt',
|
|
||||||
);
|
|
||||||
|
|
||||||
my $Rolling = Log::Dispatch::File::Rolling->new(%params);
|
|
||||||
ok($Rolling);
|
|
||||||
|
|
||||||
#########################3
|
|
||||||
|
|
||||||
$dispatcher->add($Rolling);
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################4
|
|
||||||
|
|
||||||
my $message = 'logtest id ' . int(rand(9999));
|
|
||||||
|
|
||||||
$dispatcher->log( level => 'info', message => $message );
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################5
|
|
||||||
|
|
||||||
$dispatcher = $Rolling = undef;
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################6
|
|
||||||
|
|
||||||
my @logfiles = glob("logfile$$.txt");
|
|
||||||
|
|
||||||
ok(scalar(@logfiles) == 1);
|
|
||||||
|
|
||||||
#########################7
|
|
||||||
|
|
||||||
my $content = '';
|
|
||||||
|
|
||||||
foreach my $file (@logfiles) {
|
|
||||||
open F, '<', $file;
|
|
||||||
local $/ = undef;
|
|
||||||
$content .= <F>;
|
|
||||||
close F;
|
|
||||||
unlink $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
ok($content =~ /$message/);
|
|
||||||
|
|
||||||
#########################8
|
|
70
t/5.t
70
t/5.t
@ -1,70 +0,0 @@
|
|||||||
# Before `make install' is performed this script should be runnable with
|
|
||||||
# `make test'. After `make install' it should work as `perl 1.t'
|
|
||||||
|
|
||||||
#########################
|
|
||||||
|
|
||||||
# change 'tests => 1' to 'tests => last_test_to_print';
|
|
||||||
|
|
||||||
use Test;
|
|
||||||
BEGIN { plan tests => 8 };
|
|
||||||
use Log::Dispatch;
|
|
||||||
use Log::Dispatch::File::Rolling;
|
|
||||||
ok(1); # If we made it this far, we're ok.
|
|
||||||
|
|
||||||
#########################1
|
|
||||||
|
|
||||||
my $dispatcher = Log::Dispatch->new;
|
|
||||||
ok($dispatcher);
|
|
||||||
|
|
||||||
#########################2
|
|
||||||
|
|
||||||
my %params = (
|
|
||||||
name => 'file',
|
|
||||||
min_level => 'debug',
|
|
||||||
filename => 'logfile',
|
|
||||||
);
|
|
||||||
|
|
||||||
my $Rolling = Log::Dispatch::File::Rolling->new(%params);
|
|
||||||
ok($Rolling);
|
|
||||||
|
|
||||||
#########################3
|
|
||||||
|
|
||||||
$dispatcher->add($Rolling);
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################4
|
|
||||||
|
|
||||||
my $message = 'logtest id ' . int(rand(9999));
|
|
||||||
|
|
||||||
$dispatcher->log( level => 'info', message => $message );
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################5
|
|
||||||
|
|
||||||
$dispatcher = $Rolling = undef;
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################6
|
|
||||||
|
|
||||||
my @logfiles = glob("logfile.2*");
|
|
||||||
|
|
||||||
ok(scalar(@logfiles) == 1 or scalar(@logfiles) == 2);
|
|
||||||
|
|
||||||
#########################7
|
|
||||||
|
|
||||||
my $content = '';
|
|
||||||
|
|
||||||
foreach my $file (@logfiles) {
|
|
||||||
open F, '<', $file;
|
|
||||||
local $/ = undef;
|
|
||||||
$content .= <F>;
|
|
||||||
close F;
|
|
||||||
unlink $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
ok($content =~ /$message/);
|
|
||||||
|
|
||||||
#########################8
|
|
74
t/6.t
74
t/6.t
@ -1,74 +0,0 @@
|
|||||||
# Before `make install' is performed this script should be runnable with
|
|
||||||
# `make test'. After `make install' it should work as `perl 1.t'
|
|
||||||
|
|
||||||
#########################
|
|
||||||
|
|
||||||
# change 'tests => 1' to 'tests => last_test_to_print';
|
|
||||||
|
|
||||||
use Test;
|
|
||||||
BEGIN { plan tests => 9 };
|
|
||||||
use Log::Dispatch;
|
|
||||||
use Log::Dispatch::File::Rolling;
|
|
||||||
ok(1); # If we made it this far, we're ok.
|
|
||||||
|
|
||||||
#########################1
|
|
||||||
|
|
||||||
my $dispatcher = Log::Dispatch->new;
|
|
||||||
ok($dispatcher);
|
|
||||||
|
|
||||||
#########################2
|
|
||||||
|
|
||||||
my %params = (
|
|
||||||
name => 'file',
|
|
||||||
min_level => 'debug',
|
|
||||||
filename => 'logfile.txt',
|
|
||||||
);
|
|
||||||
|
|
||||||
my $Rolling = Log::Dispatch::File::Rolling->new(%params);
|
|
||||||
ok($Rolling);
|
|
||||||
|
|
||||||
#########################3
|
|
||||||
|
|
||||||
$dispatcher->add($Rolling);
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################4
|
|
||||||
|
|
||||||
my $message1 = 'logtest id ' . int(rand(9999));
|
|
||||||
my $message2 = 'logtest id ' . int(rand(9999));
|
|
||||||
|
|
||||||
$dispatcher->log( level => 'info', message => $message1 );
|
|
||||||
close $Rolling->{fh}; # disturb internal bookkeeping, must recover from this
|
|
||||||
$dispatcher->log( level => 'info', message => $message2 );
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################5
|
|
||||||
|
|
||||||
$dispatcher = $Rolling = undef;
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################6
|
|
||||||
|
|
||||||
my @logfiles = glob('logfile*.txt');
|
|
||||||
|
|
||||||
ok(scalar(@logfiles) == 1 or scalar(@logfiles) == 2);
|
|
||||||
|
|
||||||
#########################7
|
|
||||||
|
|
||||||
my $content = '';
|
|
||||||
|
|
||||||
foreach my $file (@logfiles) {
|
|
||||||
open F, '<', $file;
|
|
||||||
local $/ = undef;
|
|
||||||
$content .= <F>;
|
|
||||||
close F;
|
|
||||||
unlink $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
ok($content =~ /$message1/);
|
|
||||||
ok($content =~ /$message2/);
|
|
||||||
|
|
||||||
#########################8
|
|
@ -1,5 +0,0 @@
|
|||||||
use Test::More;
|
|
||||||
eval "
|
|
||||||
use Test::Pod 1.00;";
|
|
||||||
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
|
|
||||||
all_pod_files_ok();
|
|
@ -1,5 +0,0 @@
|
|||||||
use Test::More;
|
|
||||||
eval "
|
|
||||||
use Test::Pod::Coverage 1.00; ";
|
|
||||||
plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@;
|
|
||||||
all_pod_coverage_ok();
|
|
@ -1,75 +0,0 @@
|
|||||||
# Before `make install' is performed this script should be runnable with
|
|
||||||
# `make test'. After `make install' it should work as `perl 1.t'
|
|
||||||
|
|
||||||
#########################
|
|
||||||
|
|
||||||
use Test::More;
|
|
||||||
eval "
|
|
||||||
use Test::Fork; ";
|
|
||||||
plan skip_all => "Test::Fork required for this test" if $@;
|
|
||||||
plan tests => 12;
|
|
||||||
|
|
||||||
use Log::Dispatch;
|
|
||||||
use Log::Dispatch::File::Rolling;
|
|
||||||
ok(1); # If we made it this far, we're ok.
|
|
||||||
|
|
||||||
#########################1
|
|
||||||
|
|
||||||
my $dispatcher = Log::Dispatch->new;
|
|
||||||
ok($dispatcher);
|
|
||||||
|
|
||||||
#########################2
|
|
||||||
|
|
||||||
my %params = (
|
|
||||||
name => 'file',
|
|
||||||
min_level => 'debug',
|
|
||||||
filename => 'logfile.txt',
|
|
||||||
);
|
|
||||||
|
|
||||||
my $Rolling = Log::Dispatch::File::Rolling->new(%params);
|
|
||||||
ok($Rolling);
|
|
||||||
|
|
||||||
#########################3
|
|
||||||
|
|
||||||
$dispatcher->add($Rolling);
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################4
|
|
||||||
|
|
||||||
my @message = map {'logtest id ' . int(rand(9999))} 1 .. 3;
|
|
||||||
|
|
||||||
my $initial_fileno = fileno $Rolling->{fh};
|
|
||||||
$dispatcher->log( level => 'info', message => $message[0] );
|
|
||||||
my $parent_fileno = fileno $Rolling->{fh};
|
|
||||||
is( $parent_fileno, $initial_fileno, "initial log call doesn't reopen" );
|
|
||||||
fork_ok( 2, sub {
|
|
||||||
$dispatcher->log( level => 'info', message => $message[1] );
|
|
||||||
my $child_fileno = fileno $Rolling->{fh};
|
|
||||||
isnt( $child_fileno, $parent_fileno, "logging in child reopens" );
|
|
||||||
$dispatcher = $Rolling = undef;
|
|
||||||
ok(1);
|
|
||||||
});
|
|
||||||
$dispatcher->log( level => 'info', message => $message[2] );
|
|
||||||
my $_parent_fileno = fileno $Rolling->{fh};
|
|
||||||
is( $_parent_fileno, $parent_fileno, "logging in parent does not reopen" );
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################5
|
|
||||||
|
|
||||||
$dispatcher = $Rolling = undef;
|
|
||||||
|
|
||||||
ok(1);
|
|
||||||
|
|
||||||
#########################6
|
|
||||||
|
|
||||||
my @logfiles = glob('logfile*.txt');
|
|
||||||
|
|
||||||
ok(scalar(@logfiles) == 1 or scalar(@logfiles) == 2);
|
|
||||||
|
|
||||||
#########################7
|
|
||||||
|
|
||||||
foreach my $file (@logfiles) {
|
|
||||||
unlink $file;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user