cvs: pear /Log/Log sql.php /Log/tests sql_ident.phpt
| From: | Jon Parise | Date: | Fri, 19 Mar 2004 08:21:25 +0000 |
| Subject: | cvs: pear /Log/Log sql.php /Log/tests sql_ident.phpt | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-17536@lists.php.net to get a copy of this message | ||
jon Fri Mar 19 03:21:25 2004 EDT
Added files:
/pear/Log/tests sql_ident.phpt
Modified files:
/pear/Log/Log sql.php
Log:
The SQL schema limits the length of the 'ident' field to 16 characters.
Enforce this requirement in the 'sql' handler by truncating the $ident
string to 16 characters. The setIdent() method has been overridden to
in the 'sql' handler to ensure consistency.
http://cvs.php.net/diff.php/pear/Log/Log/sql.php?r1=1.29&r2=1.30&ty=u
Index: pear/Log/Log/sql.php
diff -u pear/Log/Log/sql.php:1.29 pear/Log/Log/sql.php:1.30
--- pear/Log/Log/sql.php:1.29 Mon Jan 19 03:02:40 2004
+++ pear/Log/Log/sql.php Fri Mar 19 03:21:22 2004
@@ -1,9 +1,9 @@
<?php
/**
- * $Header: /repository/pear/Log/Log/sql.php,v 1.29 2004/01/19 08:02:40 jon Exp $
+ * $Header: /repository/pear/Log/Log/sql.php,v 1.30 2004/03/19 08:21:22 jon Exp $
* $Horde: horde/lib/Log/sql.php,v 1.12 2000/08/16 20:27:34 chuck Exp $
*
- * @version $Revision: 1.29 $
+ * @version $Revision: 1.30 $
* @package Log
*/
@@ -78,8 +78,8 @@
{
$this->_id = md5(microtime());
$this->_table = $name;
- $this->_ident = $ident;
$this->_mask = Log::UPTO($level);
+ $this->setIdent($ident);
/* If an existing database connection was provided, use it. */
if (isset($conf['db'])) {
@@ -130,6 +130,21 @@
}
/**
+ * Sets this Log instance's identification string. Note that this
+ * SQL-specific implementation will limit the length of the $ident string
+ * to sixteen (16) characters.
+ *
+ * @param string $ident The new identification string.
+ *
+ * @access public
+ * @since Log 1.8.5
+ */
+ function setIdent($ident)
+ {
+ $this->_ident = substr($ident, 0, 16);
+ }
+
+ /**
* Inserts $message to the currently open database. Calls open(),
* if necessary. Also passes the message along to any Log_observer
* instances that are observing this Log.
http://cvs.php.net/co.php/pear/Log/tests/sql_ident.phpt?r=1.1&p=1
Index: pear/Log/tests/sql_ident.phpt
+++ pear/Log/tests/sql_ident.phpt
--TEST--
Log: SQL setIdent()
--FILE--
<?php
require_once 'Log.php';
$ident = '12345678901234567890';
$logger = &Log::singleton('sql', 'log_table', $ident, array('dsn'
=> ''));
echo $logger->getIdent() . "\n";
$logger->setIdent($ident);
echo $logger->getIdent() . "\n";
--EXPECT--
1234567890123456
1234567890123456