r36348 - in /trunk/liblog-handler-perl: ChangeLog MANIFEST META.yml Makefile.PL README debian/changelog debian/control examples/prepare/prepare.pl examples/text-csv/ lib/Log/Handler.pm t/019-handler-setlevel.t

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Sun May 24 23:35:17 UTC 2009


Author: ansgar-guest
Date: Sun May 24 23:35:13 2009
New Revision: 36348

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=36348
Log:
* New upstream release.
* Bump Standards Version to 3.8.1 (no changes).

Added:
    trunk/liblog-handler-perl/examples/text-csv/
      - copied from r36347, branches/upstream/liblog-handler-perl/current/examples/text-csv/
    trunk/liblog-handler-perl/t/019-handler-setlevel.t
      - copied unchanged from r36347, branches/upstream/liblog-handler-perl/current/t/019-handler-setlevel.t
Modified:
    trunk/liblog-handler-perl/ChangeLog
    trunk/liblog-handler-perl/MANIFEST
    trunk/liblog-handler-perl/META.yml
    trunk/liblog-handler-perl/Makefile.PL
    trunk/liblog-handler-perl/README
    trunk/liblog-handler-perl/debian/changelog
    trunk/liblog-handler-perl/debian/control
    trunk/liblog-handler-perl/examples/prepare/prepare.pl
    trunk/liblog-handler-perl/lib/Log/Handler.pm

Modified: trunk/liblog-handler-perl/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/ChangeLog?rev=36348&op=diff
==============================================================================
--- trunk/liblog-handler-perl/ChangeLog (original)
+++ trunk/liblog-handler-perl/ChangeLog Sun May 24 23:35:13 2009
@@ -1,3 +1,13 @@
+0.52    Released at 2009-05-24.
+        - No changes, just a full version.
+
+0.51_01 Released at 2009-05-22.
+        - Added method set_level() to Handler.pm to change the log
+          level at runtime.
+
+0.51    Released at 2009-03-07.
+        - Just a full release.
+
 0.50_01 Released at 2009-03-07.
         - Fixed a bug in the output DBI.pm - if the connection to
           the database was lost then the message lost as well even

Modified: trunk/liblog-handler-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/MANIFEST?rev=36348&op=diff
==============================================================================
--- trunk/liblog-handler-perl/MANIFEST (original)
+++ trunk/liblog-handler-perl/MANIFEST Sun May 24 23:35:13 2009
@@ -16,6 +16,7 @@
 examples/prepare/prepare.pl
 examples/socket/client.pl
 examples/socket/server.pl
+examples/text-csv/log-as-csv-string.pl
 INSTALL
 lib/Log/Handler.pm
 lib/Log/Handler/Config.pm
@@ -50,6 +51,7 @@
 t/016-handler-alias.t
 t/017-handler-special-levels.t
 t/018-handler-logger.t
+t/019-handler-setlevel.t
 t/020-output-forward.t
 t/030-output-file.t
 t/040-output-email.t

Modified: trunk/liblog-handler-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/META.yml?rev=36348&op=diff
==============================================================================
--- trunk/liblog-handler-perl/META.yml (original)
+++ trunk/liblog-handler-perl/META.yml Sun May 24 23:35:13 2009
@@ -1,6 +1,6 @@
 ---
 name: Log-Handler
-version: 0.51
+version: 0.52
 author:
   - Jonny Schulz
 abstract: Log messages to several outputs.
@@ -30,7 +30,7 @@
 provides:
   Log::Handler:
     file: lib/Log/Handler.pm
-    version: 0.51
+    version: 0.52
   Log::Handler::Config:
     file: lib/Log/Handler/Config.pm
     version: 0.04

Modified: trunk/liblog-handler-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/Makefile.PL?rev=36348&op=diff
==============================================================================
--- trunk/liblog-handler-perl/Makefile.PL (original)
+++ trunk/liblog-handler-perl/Makefile.PL Sun May 24 23:35:13 2009
@@ -5,17 +5,17 @@
           'NAME' => 'Log::Handler',
           'VERSION_FROM' => 'lib/Log/Handler.pm',
           'PREREQ_PM' => {
-                           'Carp' => '0',
-                           'Data::Dumper' => '0',
+                           'Carp' => 0,
+                           'Data::Dumper' => 0,
                            'Devel::Backtrace' => '0.05',
-                           'Fcntl' => '0',
-                           'File::Spec' => '0',
-                           'POSIX' => '0',
-                           'Params::Validate' => '0',
-                           'Sys::Hostname' => '0',
-                           'Test::More' => '0',
-                           'Time::HiRes' => '0',
-                           'UNIVERSAL::require' => '0'
+                           'Fcntl' => 0,
+                           'File::Spec' => 0,
+                           'POSIX' => 0,
+                           'Params::Validate' => 0,
+                           'Sys::Hostname' => 0,
+                           'Test::More' => 0,
+                           'Time::HiRes' => 0,
+                           'UNIVERSAL::require' => 0
                          },
           'INSTALLDIRS' => 'site',
           'EXE_FILES' => []

Modified: trunk/liblog-handler-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/README?rev=36348&op=diff
==============================================================================
--- trunk/liblog-handler-perl/README (original)
+++ trunk/liblog-handler-perl/README Sun May 24 23:35:13 2009
@@ -136,11 +136,13 @@
         This option is not used by default.
 
     newline
-        Option "newline" is a very helpful option. It let the logger appends
-        a newline to the message if a newline doesn't exist.
+        "newline" is a very helpful option. It let the logger appends a
+        newline to the message if a newline doesn't exist.
 
             0 - do nothing (default)
             1 - append a newline if not exist
+
+        Example:
 
             $log->add(
                 screen => {
@@ -272,14 +274,15 @@
             $log->add(
                 screen => {
                     newline => 1,
+                    message_layout  => '%m (%t)',
                     message_pattern => [ qw/%T %L %H %m/ ],
                     prepare_message => \&format,
                 }
             );
 
-            $log->error("foo bar baz");
-            $log->error("foo bar baz");
-            $log->error("foo bar baz");
+            $log->error("foo");
+            $log->error("bar");
+            $log->error("baz");
 
             sub format {
                 my $m = shift;
@@ -290,9 +293,9 @@
 
         The output looks like
 
-            Mar 07 20:06:39      ERROR                h1434036             Mar 07 20:06:39 [ERROR] foo bar baz
-            Mar 07 20:06:39      ERROR                h1434036             Mar 07 20:06:39 [ERROR] foo bar baz
-            Mar 07 20:06:39      ERROR                h1434036             Mar 07 20:06:39 [ERROR] foo bar baz
+            Mar 08 15:14:20      ERROR                h1434036             foo (0.039694)
+            Mar 08 15:14:20      ERROR                h1434036             bar (0.000510)
+            Mar 08 15:14:20      ERROR                h1434036             baz (0.000274)
 
     priority
         With this option you can set the priority of your output objects.
@@ -421,7 +424,7 @@
         This would only log the message from the package "Foo::Bar".
 
     except_caller
-        This options is just the opposite of "filter_caller".
+        This option is just the opposite of "filter_caller".
 
         If you want to log messages from all callers but "Foo::Bar":
 
@@ -784,6 +787,19 @@
 
     Note: valid character for the key name are: "[%\w\-\.]+"
 
+  set_level()
+    With this method it's possible to change the log level at runtime.
+
+    To change the log level it's neccessary to use a alias - see option
+    "alias".
+
+        $log->set_level(
+            $alias => { # option alias
+                minlevel => $new_minlevel,
+                maxlevel => $new_maxlevel,
+            }
+        );
+
   create_logger()
     "create_logger()" is the same like "new()" but it creates a global
     logger.
@@ -806,7 +822,7 @@
 
     Or
 
-        my @logger = Log::Handler->create_logger('myapp1', 'myapp2', ...);
+        my @logger = Log::Handler->get_logger('myapp1', 'myapp2', ...);
 
 GLOBAL LOG HANDLER
     Since version 0.50 it's possible to define a application logger. This
@@ -821,8 +837,8 @@
     If the alias doesn't exists then a new "Log::Handler" object will be
     created.
 
-    If no acesseor is set then no accessor is exported into the namespace of
-    the caller.
+    If no accesseor is set then no accessor is exported into the namespace
+    of the caller.
 
     Example:
 

Modified: trunk/liblog-handler-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/debian/changelog?rev=36348&op=diff
==============================================================================
--- trunk/liblog-handler-perl/debian/changelog (original)
+++ trunk/liblog-handler-perl/debian/changelog Sun May 24 23:35:13 2009
@@ -1,3 +1,10 @@
+liblog-handler-perl (0.52-1) unstable; urgency=low
+
+  * New upstream release.
+  * Bump Standards Version to 3.8.1 (no changes).
+
+ -- Ansgar Burchardt <ansgar at 43-1.org>  Mon, 25 May 2009 01:30:22 +0200
+
 liblog-handler-perl (0.51-1) unstable; urgency=low
 
   * New upstream release

Modified: trunk/liblog-handler-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/debian/control?rev=36348&op=diff
==============================================================================
--- trunk/liblog-handler-perl/debian/control (original)
+++ trunk/liblog-handler-perl/debian/control Sun May 24 23:35:13 2009
@@ -9,7 +9,7 @@
 Uploaders: Roberto C. Sanchez <roberto at connexer.com>,
  gregor herrmann <gregoa at debian.org>, Rene Mayorga <rmayorga at debian.org.sv>,
  Ansgar Burchardt <ansgar at 43-1.org>, Ryan Niebur <ryanryan52 at gmail.com>
-Standards-Version: 3.8.0
+Standards-Version: 3.8.1
 Homepage: http://search.cpan.org/dist/Log-Handler/
 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/liblog-handler-perl/
 Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/liblog-handler-perl/

Modified: trunk/liblog-handler-perl/examples/prepare/prepare.pl
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/examples/prepare/prepare.pl?rev=36348&op=diff
==============================================================================
--- trunk/liblog-handler-perl/examples/prepare/prepare.pl (original)
+++ trunk/liblog-handler-perl/examples/prepare/prepare.pl Sun May 24 23:35:13 2009
@@ -34,6 +34,7 @@
 $log->add(
     screen => {
         newline => 1,
+        message_layout  => '%m (%t)',
         message_pattern => [ qw/%T %L %H %m/ ],
         prepare_message => \&format,
     }

Modified: trunk/liblog-handler-perl/lib/Log/Handler.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/lib/Log/Handler.pm?rev=36348&op=diff
==============================================================================
--- trunk/liblog-handler-perl/lib/Log/Handler.pm (original)
+++ trunk/liblog-handler-perl/lib/Log/Handler.pm Sun May 24 23:35:13 2009
@@ -145,12 +145,13 @@
 
 =item B<newline>
 
-Option C<newline> is a very helpful option. It let the logger appends a newline to
+C<newline> is a very helpful option. It let the logger appends a newline to
 the message if a newline doesn't exist.
 
     0 - do nothing (default)
     1 - append a newline if not exist
 
+Example:
 
     $log->add(
         screen => {
@@ -283,14 +284,15 @@
     $log->add(
         screen => {
             newline => 1,
+            message_layout  => '%m (%t)',
             message_pattern => [ qw/%T %L %H %m/ ],
             prepare_message => \&format,
         }
     );
 
-    $log->error("foo bar baz");
-    $log->error("foo bar baz");
-    $log->error("foo bar baz");
+    $log->error("foo");
+    $log->error("bar");
+    $log->error("baz");
 
     sub format {
         my $m = shift;
@@ -301,9 +303,9 @@
 
 The output looks like
 
-    Mar 07 20:06:39      ERROR                h1434036             Mar 07 20:06:39 [ERROR] foo bar baz
-    Mar 07 20:06:39      ERROR                h1434036             Mar 07 20:06:39 [ERROR] foo bar baz
-    Mar 07 20:06:39      ERROR                h1434036             Mar 07 20:06:39 [ERROR] foo bar baz
+    Mar 08 15:14:20      ERROR                h1434036             foo (0.039694)
+    Mar 08 15:14:20      ERROR                h1434036             bar (0.000510)
+    Mar 08 15:14:20      ERROR                h1434036             baz (0.000274)
 
 =item B<priority>
 
@@ -433,7 +435,7 @@
 
 =item B<except_caller>
 
-This options is just the opposite of C<filter_caller>.
+This option is just the opposite of C<filter_caller>.
 
 If you want to log messages from all callers but C<Foo::Bar>:
 
@@ -823,6 +825,19 @@
 
 Note: valid character for the key name are: C<[%\w\-\.]+>
 
+=head2 set_level()
+
+With this method it's possible to change the log level at runtime.
+
+To change the log level it's neccessary to use a alias - see option C<alias>.
+
+    $log->set_level(
+        $alias => { # option alias
+            minlevel => $new_minlevel,
+            maxlevel => $new_maxlevel,
+        }
+    );
+
 =head2 create_logger()
 
 C<create_logger()> is the same like C<new()> but it creates a global
@@ -847,7 +862,7 @@
 
 Or
 
-    my @logger = Log::Handler->create_logger('myapp1', 'myapp2', ...);
+    my @logger = Log::Handler->get_logger('myapp1', 'myapp2', ...);
 
 =head1 GLOBAL LOG HANDLER
 
@@ -863,7 +878,7 @@
 If the alias doesn't exists then a new C<Log::Handler> object
 will be created.
 
-If no acesseor is set then no accessor is exported into the
+If no accesseor is set then no accessor is exported into the
 namespace of the caller.
 
 Example:
@@ -1017,7 +1032,7 @@
 use Log::Handler::Pattern;
 use base qw(Log::Handler::Levels);
 
-our $VERSION = '0.51';
+our $VERSION = '0.52';
 our $ERRSTR  = '';
 
 # $TRACE and $CALLER_LEVEL are both used as global
@@ -1249,6 +1264,67 @@
     #   $self->{pattern}->{'%X'}->{code} = 'value-of-x';
     $self->{pattern}->{$pattern}->{name} = $name;
     $self->{pattern}->{$pattern}->{code} = $code;
+}
+
+sub set_level {
+    @_ == 3 or Carp::croak 'Usage: $log->set_level( $alias => { minlevel => $min, maxlevel => $max } )';
+    my ($self, $name, $new) = @_;
+    my $alias = $self->{alias};
+
+    if (!exists $alias->{$name}) {
+        Carp::croak "alias '$name' does not exists";
+    }
+
+    if (ref($new) ne 'HASH') {
+        Carp::croak "the second parameter to set_level() must be a hash reference";
+    }
+
+    if (!defined $new->{minlevel} && !defined $new->{maxlevel}) {
+        Carp::croak "no new level given to set_level()";
+    }
+
+    foreach my $level (qw/minlevel maxlevel/) {
+        next unless defined $new->{$level};
+
+        if ($new->{$level} =~ LEVEL_RX) {
+            $alias->{$name}->{$level} = $new->{$level};
+            next if $new->{$level} =~ /^\d\z/;
+            $new->{$level} = uc($new->{$level});
+            $new->{$level} = $LEVEL_BY_STRING{ $new->{$level} };
+            $alias->{$name}->{$level} = $new->{$level};
+        } else {
+            Carp::croak "invalid level set to set_level()";
+        }
+    }
+
+    $alias->{$name}->{levels} = { };
+    my $levels = $self->{levels} = { };
+
+    foreach my $level_num ($alias->{$name}->{minlevel} .. $alias->{$name}->{maxlevel}) {
+        my $level = $LEVEL_BY_NUM[ $level_num ];
+        $alias->{$name}->{levels}->{$level} = 1;
+
+        if ($level_num < 4) {
+            $alias->{$name}->{levels}->{FATAL} = 1;
+        }
+    }
+
+    foreach my $output (@{ $self->{outputs} }) {
+        foreach my $level (keys %{$output->{levels}}) {
+            if ($levels->{$level}) {
+                my @old_order = @{$levels->{$level}};
+                $levels->{$level} = [
+                    map  { $_->[0] }
+                    sort { $a->[1] <=> $b->[1] }
+                    map  { [ $_, $_->{priority} ] } @old_order
+                ];
+            } else {
+                push @{$levels->{$level}}, $output;
+            }
+        }
+    }
+
+    return 1;
 }
 
 sub output {
@@ -1378,7 +1454,7 @@
 
 sub _validate_options {
     my ($self, @args) = @_;
-    my (%wanted, $is_fatal);
+    my %wanted  = ();
     my $pattern = $self->{pattern};
 
     # Option 'filter' is deprecated.
@@ -1490,7 +1566,7 @@
     foreach my $level_num ($options{minlevel} .. $options{maxlevel}) {
         my $level = $LEVEL_BY_NUM[ $level_num ];
         $options{levels}{$level} = 1;
-        next if $is_fatal || $level_num > 3;
+        next if $level_num > 3;
         $options{levels}{FATAL} = 1;
     }
 




More information about the Pkg-perl-cvs-commits mailing list