r36895 - in /branches/upstream/liblog-handler-perl/current: ChangeLog META.yml lib/Log/Handler.pm lib/Log/Handler/Examples.pod lib/Log/Handler/Output/DBI.pm t/050-output-dbi.t

carnil-guest at users.alioth.debian.org carnil-guest at users.alioth.debian.org
Sun May 31 08:37:52 UTC 2009


Author: carnil-guest
Date: Sun May 31 08:37:47 2009
New Revision: 36895

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=36895
Log:
[svn-upgrade] Integrating new upstream version, liblog-handler-perl (0.54)

Modified:
    branches/upstream/liblog-handler-perl/current/ChangeLog
    branches/upstream/liblog-handler-perl/current/META.yml
    branches/upstream/liblog-handler-perl/current/lib/Log/Handler.pm
    branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Examples.pod
    branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Output/DBI.pm
    branches/upstream/liblog-handler-perl/current/t/050-output-dbi.t

Modified: branches/upstream/liblog-handler-perl/current/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/ChangeLog?rev=36895&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/ChangeLog (original)
+++ branches/upstream/liblog-handler-perl/current/ChangeLog Sun May 31 08:37:47 2009
@@ -1,3 +1,12 @@
+0.54    Released at 2009-05-27.
+        - Just a full version.
+
+0.53_01 Released at 2009-05-27.
+        - Fixed a bug in Log::Handler::Output::DBI - it was unable
+          to create a valid dsn for sqlite (RT #46407).
+          - Added option dbname
+          - Added option data_source
+
 0.52    Released at 2009-05-24.
         - No changes, just a full version.
 

Modified: branches/upstream/liblog-handler-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/META.yml?rev=36895&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/META.yml (original)
+++ branches/upstream/liblog-handler-perl/current/META.yml Sun May 31 08:37:47 2009
@@ -1,6 +1,6 @@
 ---
 name: Log-Handler
-version: 0.52
+version: 0.54
 author:
   - Jonny Schulz
 abstract: Log messages to several outputs.
@@ -30,7 +30,7 @@
 provides:
   Log::Handler:
     file: lib/Log/Handler.pm
-    version: 0.52
+    version: 0.54
   Log::Handler::Config:
     file: lib/Log/Handler/Config.pm
     version: 0.04
@@ -42,7 +42,7 @@
     version: 0.06
   Log::Handler::Output::DBI:
     file: lib/Log/Handler/Output/DBI.pm
-    version: 0.04
+    version: 0.06
   Log::Handler::Output::Email:
     file: lib/Log/Handler/Output/Email.pm
     version: 0.03

Modified: branches/upstream/liblog-handler-perl/current/lib/Log/Handler.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/lib/Log/Handler.pm?rev=36895&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/lib/Log/Handler.pm (original)
+++ branches/upstream/liblog-handler-perl/current/lib/Log/Handler.pm Sun May 31 08:37:47 2009
@@ -1032,7 +1032,7 @@
 use Log::Handler::Pattern;
 use base qw(Log::Handler::Levels);
 
-our $VERSION = '0.52';
+our $VERSION = '0.54';
 our $ERRSTR  = '';
 
 # $TRACE and $CALLER_LEVEL are both used as global

Modified: branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Examples.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Examples.pod?rev=36895&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Examples.pod (original)
+++ branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Examples.pod Sun May 31 08:37:47 2009
@@ -107,19 +107,15 @@
 
     $log->add(
         dbi => {
-            # database connection
             database   => 'database',
             driver     => 'mysql',
+            host       => '127.0.0.1',
+            port       => 3306,
             user       => 'user',
             password   => 'password',
-            host       => '127.0.0.1',
-            port       => 3306,
-            debug      => 1,
             table      => 'messages',
             columns    => [ qw/level ctime cdate pid hostname caller progname mtime message/ ],
             values     => [ qw/%level %time %date %pid %hostname %caller %progname %mtime %message/ ],
-            persistent => 1,
-            reconnect  => 1,
             maxlevel   => 'error',
             minlevel   => 'emergency'
             message_pattern => '%L %T %D %P %H %C %S %t %m',
@@ -127,6 +123,39 @@
     );
 
     $log->error('log an error');
+
+Or with C<dbname>
+
+    $log->add(
+        dbi => {
+            dbname     => 'database',
+            driver     => 'Pg',
+            host       => '127.0.0.1',
+            port       => 5432,
+            user       => 'user',
+            password   => 'password',
+            table      => 'messages',
+            columns    => [ qw/level ctime cdate pid hostname caller progname mtime message/ ],
+            values     => [ qw/%level %time %date %pid %hostname %caller %progname %mtime %message/ ],
+            maxlevel   => 'error',
+            minlevel   => 'emergency'
+            message_pattern => '%L %T %D %P %H %C %S %t %m',
+        }
+    );
+
+Or with C<data_source>
+
+    $log->add(
+        dbi => {
+            data_source => 'dbi:SQLite:dbname=database.sqlite',
+            table       => 'messages',
+            columns     => [ qw/level ctime cdate pid hostname caller progname mtime message/ ],
+            values      => [ qw/%level %time %date %pid %hostname %caller %progname %mtime %message/ ],
+            maxlevel    => 'error',
+            minlevel    => 'emergency'
+            message_pattern => '%L %T %D %P %H %C %S %t %m',
+        }
+    );
 
 =head1 LOG VIA EMAIL
 

Modified: branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Output/DBI.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Output/DBI.pm?rev=36895&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Output/DBI.pm (original)
+++ branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Output/DBI.pm Sun May 31 08:37:47 2009
@@ -7,33 +7,44 @@
     use Log::Handler::Output::DBI;
 
     my $db = Log::Handler::Output::DBI->new(
-        # database connection
-        database   => 'database',
-        driver     => 'mysql',
-        user       => 'user',
-        password   => 'password',
-        host       => '127.0.0.1',
-        port       => 3306,
+        # database source
+        database    => 'database',
+        driver      => 'mysql',
+        host        => '127.0.0.1',
+        port        => 3306,
+
+        # or with "dbname" instead of "database"
+        dbname      => 'database',
+        driver      => 'Pg',
+        host        => '127.0.0.1',
+        port        => 5432,
+
+        # or with data_source
+        data_source => 'dbi:mysql:database=database;host=127.0.0.1;port=3306',
+
+        # Username and password
+        user        => 'user',
+        password    => 'password',
 
         # debugging
-        debug      => 1,
+        debug       => 1,
 
         # table, columns and values (as string)
-        table      => 'messages',
-        columns    => 'level ctime cdate pid hostname progname message',
-        values     => '%level %time %date %pid %hostname %progname %message',
+        table       => 'messages',
+        columns     => 'level ctime cdate pid hostname progname message',
+        values      => '%level %time %date %pid %hostname %progname %message',
 
         # table, columns and values (as array reference)
-        table      => 'messages',
-        columns    => [ qw/level ctime cdate pid hostname progname message/ ],
-        values     => [ qw/%level %time %date %pid %hostname %progname %message/ ],
+        table       => 'messages',
+        columns     => [ qw/level ctime cdate pid hostname progname message/ ],
+        values      => [ qw/%level %time %date %pid %hostname %progname %message/ ],
 
         # table, columns and values (your own statement)
-        statement  => 'insert into messages (level,ctime,cdate,pid,hostname,progname,message) values (?,?,?,?,?,?,?)',
-        values     => [ qw/%level %time %date %pid %hostname %progname %message/ ],
+        statement   => 'insert into messages (level,ctime,cdate,pid,hostname,progname,message) values (?,?,?,?,?,?,?)',
+        values      => [ qw/%level %time %date %pid %hostname %progname %message/ ],
 
         # if you like persistent connections and want to re-connect
-        persistent => 1,
+        persistent  => 1,
     );
 
     my %message = (
@@ -62,7 +73,14 @@
 
 =over 4
 
-=item B<database>
+=item B<data_source>
+
+Set the dsn (data source name).
+
+You can use this parameter instead of C<database>, C<driver>, C<host>
+and C<port>.
+
+=item B<database> or B<dbname>
 
 Pass the database name.
 
@@ -252,7 +270,7 @@
 use DBI;
 use Params::Validate;
 
-our $VERSION = '0.04';
+our $VERSION = '0.06';
 our $ERRSTR  = '';
 
 sub new {
@@ -358,11 +376,21 @@
     my $class = shift;
 
     my %options = Params::Validate::validate(@_, {
+        data_source => {
+            type => Params::Validate::SCALAR,
+            optional => 1,
+        },
         database => {
             type => Params::Validate::SCALAR,
+            optional => 1,
+        },
+        dbname => {
+            type => Params::Validate::SCALAR,
+            optional => 1,
         },
         driver => {
             type => Params::Validate::SCALAR,
+            optional => 1,
         },
         user => {
             type => Params::Validate::SCALAR,
@@ -370,12 +398,11 @@
         },
         password => {
             type => Params::Validate::SCALAR,
-            depends => [ 'user' ],
+            optional => 1,
         },
         host => {
             type => Params::Validate::SCALAR,
             optional => 1,
-            depends => [ 'port' ],
         },
         port => {
             type => Params::Validate::SCALAR,
@@ -421,19 +448,33 @@
         Carp::croak "Missing one of the mandatory options: 'statement' or 'table' and 'columns'";
     }
 
-    # build the connect string
-    my @cstr = ("dbi:$options{driver}:database=$options{database}");
-
-    if ($options{host}) {
-        $cstr[0] .= ";host=$options{host}";
-        if ($options{port}) {
-            $cstr[0] .= ";port=$options{port}";
-        }
+    # build the connect string (data source name)
+    my @cstr = ();
+
+    if (defined $options{data_source}) {
+        @cstr = ($options{data_source});
+    } elsif ($options{driver} && ($options{database} || $options{dbname})) {
+        $cstr[0] = "dbi:$options{driver}:";
+
+        if ($options{database}) {
+            $cstr[0] .= "database=$options{database}";
+        } else {
+            $cstr[0] .= "dbname=$options{dbname}";
+        }
+
+        if ($options{host}) {
+            $cstr[0] .= ";host=$options{host}";
+            if ($options{port}) {
+                $cstr[0] .= ";port=$options{port}";
+            }
+        }
+    } else {
+        Carp::croak "Missing mandatory options data_source or database/dbname";
     }
 
     if ($options{user}) {
         $cstr[1] = $options{user};
-        if ($options{port}) {
+        if ($options{password}) {
             $cstr[2] = $options{password};
         }
     }

Modified: branches/upstream/liblog-handler-perl/current/t/050-output-dbi.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/t/050-output-dbi.t?rev=36895&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/t/050-output-dbi.t (original)
+++ branches/upstream/liblog-handler-perl/current/t/050-output-dbi.t Sun May 31 08:37:47 2009
@@ -35,6 +35,7 @@
 $ret = $log->{statement} eq 'insert into messages (level,message) values (?,?)';
 ok($ret, 'checking statement');
 
+#$ret = $log->{cstr}->[0] eq 'dbi:mysql:database=dbname;host=127.0.0.1;port=3306';
 $ret = $log->{cstr}->[0] eq 'dbi:mysql:database=dbname;host=127.0.0.1;port=3306';
 ok($ret, 'checking cstr');
 




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