Permalink
Browse files

This commit was manufactured by cvs2svn to create tag 'RELEASE_1_9_16'.

  • Loading branch information...
1 parent 675de2a commit d70485c0c053623a770e94591e4f9f72745cadba PHP SVN committed Jan 19, 2008
View
12 docs/examples/composite.php
@@ -0,0 +1,12 @@
+<?php
+
+require_once 'Log.php';
+
+$console = &Log::singleton('console', '', 'TEST');
+$file = &Log::singleton('file', 'out.log', 'TEST');
+
+$composite = &Log::singleton('composite');
+$composite->addChild($console);
+$composite->addChild($file);
+
+$composite->log('This event will be logged to both handlers.');
View
8 docs/examples/console.php
@@ -0,0 +1,8 @@
+<?php
+
+require_once 'Log.php';
+
+$logger = &Log::singleton('console', '', 'ident');
+for ($i = 0; $i < 10; $i++) {
+ $logger->log("Log entry $i");
+}
View
10 docs/examples/display.php
@@ -0,0 +1,10 @@
+<?php
+
+require_once 'Log.php';
+
+$conf = array('error_prepend' => '<font color="#ff0000"><tt>',
+ 'error_append' => '</tt></font>');
+$logger = &Log::singleton('display', '', '', $conf, PEAR_LOG_DEBUG);
+for ($i = 0; $i < 10; $i++) {
+ $logger->log("Log entry $i");
+}
View
8 docs/examples/error_log.php
@@ -0,0 +1,8 @@
+<?php
+
+require_once 'Log.php';
+
+$logger = &Log::singleton('error_log', PEAR_LOG_TYPE_SYSTEM, 'ident');
+for ($i = 0; $i < 10; $i++) {
+ $logger->log("Log entry $i");
+}
View
9 docs/examples/file.php
@@ -0,0 +1,9 @@
+<?php
+
+require_once 'Log.php';
+
+$conf = array('mode' => 0600, 'timeFormat' => '%X %x');
+$logger = &Log::singleton('file', 'out.log', 'ident', $conf);
+for ($i = 0; $i < 10; $i++) {
+ $logger->log("Log entry $i");
+}
View
12 docs/examples/firebug.php
@@ -0,0 +1,12 @@
+<?php
+
+require_once 'Log.php';
+
+$logger = &Log::singleton('firebug', '',
+ 'PHP',
+ array('buffering' => true),
+ PEAR_LOG_DEBUG);
+
+for ($i = 0; $i < 10; $i++) {
+ $logger->log("Log entry $i");
+}
View
9 docs/examples/mail.php
@@ -0,0 +1,9 @@
+<?php
+
+require_once 'Log.php';
+
+$conf = array('subject' => 'Important Log Events');
+$logger = &Log::singleton('mail', 'webmaster@example.com', 'ident', $conf);
+for ($i = 0; $i < 10; $i++) {
+ $logger->log("Log entry $i");
+}
View
8 docs/examples/null.php
@@ -0,0 +1,8 @@
+<?php
+
+require_once 'Log.php';
+
+$logger = &Log::singleton('null');
+for ($i = 0; $i < 10; $i++) {
+ $logger->log("Log entry $i");
+}
View
30 docs/examples/observer_mail.php
@@ -0,0 +1,30 @@
+<?php
+
+require_once 'Log/observer.php';
+
+class Log_observer_mail extends Log_observer
+{
+ var $_to = '';
+ var $_subject = '';
+ var $_pattern = '';
+
+ function Log_observer_mail($priority, $conf)
+ {
+ /* Call the base class constructor. */
+ $this->Log_observer($priority);
+
+ /* Configure the observer. */
+ $this->_to = $conf['to'];
+ $this->_subject = $conf['subject'];
+ $this->_pattern = $conf['pattern'];
+ }
+
+ function notify($event)
+ {
+ if (preg_match($this->_pattern, $event['message']) != 0) {
+ mail($this->_to, $this->_subject, $event['message']);
+ }
+ }
+}
+
+?>
View
25 docs/examples/pear_error_handler.php
@@ -0,0 +1,25 @@
+<?php
+
+require_once 'Log.php';
+
+function errorHandler($error)
+{
+ global $logger;
+
+ $message = $error->getMessage();
+
+ if (!empty($error->backtrace[1]['file'])) {
+ $message .= ' (' . $error->backtrace[1]['file'];
+ if (!empty($error->backtrace[1]['line'])) {
+ $message .= ' at line ' . $error->backtrace[1]['line'];
+ }
+ $message .= ')';
+ }
+
+ $logger->log($message, $error->code);
+}
+
+$logger = &Log::singleton('console', '', 'ident');
+
+PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errorHandler');
+PEAR::raiseError('This is an information log message.', PEAR_LOG_INFO);
View
34 docs/examples/php_error_handler.php
@@ -0,0 +1,34 @@
+<?php
+
+require_once 'Log.php';
+
+function errorHandler($code, $message, $file, $line)
+{
+ global $logger;
+
+ /* Map the PHP error to a Log priority. */
+ switch ($code) {
+ case E_WARNING:
+ case E_USER_WARNING:
+ $priority = PEAR_LOG_WARNING;
+ break;
+ case E_NOTICE:
+ case E_USER_NOTICE:
+ $priority = PEAR_LOG_NOTICE;
+ break;
+ case E_ERROR:
+ case E_USER_ERROR:
+ $priority = PEAR_LOG_ERR;
+ break;
+ default:
+ $priotity = PEAR_LOG_INFO;
+ }
+
+ $logger->log($message . ' in ' . $file . ' at line ' . $line,
+ $priority);
+}
+
+$logger = &Log::singleton('console', '', 'ident');
+
+set_error_handler('errorHandler');
+trigger_error('This is an information log message.', E_USER_NOTICE);
View
9 docs/examples/sql.php
@@ -0,0 +1,9 @@
+<?php
+
+require_once 'Log.php';
+
+$conf = array('dsn' => 'pgsql://jon@localhost+unix/logs');
+$logger = &Log::singleton('sql', 'log_table', 'ident', $conf);
+for ($i = 0; $i < 10; $i++) {
+ $logger->log("Log entry $i");
+}
View
14 docs/examples/sqlite.php
@@ -0,0 +1,14 @@
+<?php
+
+require_once 'Log.php';
+
+/* Creating a new database connection. */
+$conf = array('filename' => 'log.db', 'mode' => 0666, 'persistent' => true);
+$logger =& Log::factory('sqlite', 'log_table', 'ident', $conf);
+$logger->log('logging an event', PEAR_LOG_WARNING);
+
+/* Using an existing database connection. */
+$db = sqlite_open('log.db', 0666, $error);
+$logger =& Log::factory('sqlite', 'log_table', 'ident', $db);
+$logger->log('logging an event', PEAR_LOG_WARNING);
+sqlite_close($db);
View
8 docs/examples/syslog.php
@@ -0,0 +1,8 @@
+<?php
+
+require_once 'Log.php';
+
+$logger = &Log::singleton('syslog', LOG_LOCAL0, 'ident');
+for ($i = 0; $i < 10; $i++) {
+ $logger->log("Log entry $i");
+}
View
9 docs/examples/win.php
@@ -0,0 +1,9 @@
+<?php
+
+require_once 'Log.php';
+
+$conf = array('title' => 'Sample Log Output');
+$logger = &Log::singleton('win', 'LogWindow', 'ident', $conf);
+for ($i = 0; $i < 10; $i++) {
+ $logger->log("Log entry $i");
+}
View
65 package.php
@@ -1,65 +0,0 @@
-<?php
-
-require_once 'PEAR/PackageFileManager2.php';
-PEAR::setErrorHandling(PEAR_ERROR_DIE);
-
-$desc = <<<EOT
-The Log package provides an abstracted logging framework. It includes output handlers for log files, databases, syslog, email, Firebug, and the console. It also provides composite and subject-observer logging mechanisms.
-EOT;
-
-$version = '1.9.16';
-$notes = <<<EOT
-- Corrected some PHPDoc syntax problems.
-- Correcting some spelling errors in the users guide.
-- Fixed the firebug unit test.
-- Simplified the PEAR_LOG_ALL and PEAR_LOG_NONE constants.
-EOT;
-
-$package = new PEAR_PackageFileManager2();
-
-$result = $package->setOptions(array(
- 'filelistgenerator' => 'cvs',
- 'changelogoldtonew' => false,
- 'simpleoutput' => true,
- 'baseinstalldir' => '/',
- 'packagefile' => 'package.xml',
- 'packagedirectory' => '.'));
-
-if (PEAR::isError($result)) {
- echo $result->getMessage();
- die();
-}
-
-$package->setPackage('Log');
-$package->setPackageType('php');
-$package->setSummary('Logging Framework');
-$package->setDescription($desc);
-$package->setChannel('pear.php.net');
-$package->setLicense('PHP License', 'http://www.php.net/license/3_01.txt');
-$package->setAPIVersion('1.0.0');
-$package->setAPIStability('stable');
-$package->setReleaseVersion($version);
-$package->setReleaseStability('stable');
-$package->setNotes($notes);
-$package->setPhpDep('4.3.0');
-$package->setPearinstallerDep('1.4.3');
-$package->addMaintainer('lead', 'jon', 'Jon Parise', 'jon@php.net');
-$package->addMaintainer('lead', 'chagenbu', 'Chuck Hagenbuch', 'chuck@horde.org');
-$package->addMaintainer('lead', 'yunosh', 'Jan Schneider', 'jan@horde.org');
-$package->addIgnore(array('package.php', 'phpdoc.sh', 'package.xml'));
-$package->addPackageDepWithChannel('optional', 'DB', 'pear.php.net', '1.3');
-$package->addPackageDepWithChannel('optional', 'MDB2', 'pear.php.net', '2.0.0RC1');
-$package->addExtensionDep('optional', 'sqlite');
-
-$package->generateContents();
-
-if ($_SERVER['argv'][1] == 'commit') {
- $result = $package->writePackageFile();
-} else {
- $result = $package->debugPackageFile();
-}
-
-if (PEAR::isError($result)) {
- echo $result->getMessage();
- die();
-}
View
3 phpdoc.sh
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-phpdoc -f Log.php -d Log -t docs/api -p -ti "Log Package API" -dn Log -dc Log -ed examples -i CVS/*

0 comments on commit d70485c

Please sign in to comment.