Skip to content
Snippets Groups Projects
Commit 8e09f021 authored by David Prévot's avatar David Prévot
Browse files

Imported Upstream version 1.12.7

parent f2824448
No related branches found
No related tags found
No related merge requests found
Showing
with 73 additions and 19 deletions
......@@ -3,7 +3,7 @@
* $Header$
* $Horde: horde/lib/Log.php,v 1.15 2000/06/29 23:39:45 jon Exp $
*
* @version $Revision: 302787 $
* @version $Revision: 310238 $
* @package Log
*/
......@@ -85,6 +85,15 @@ class Log
*/
var $_listeners = array();
/**
* Starting depth to use when walking a backtrace in search of the
* function that invoked the log system.
*
* @var integer
* @access protected
*/
var $_backtrace_depth = 0;
/**
* Maps canonical format keys to position arguments for use in building
* "line format" strings.
......@@ -502,6 +511,21 @@ class Log
return array($file, $line, $func, $class);
}
/**
* Sets the starting depth to use when walking a backtrace in search of
* the function that invoked the log system. This is used on conjunction
* with the 'file', 'line', 'function', and 'class' formatters.
*
* @param int $depth The new backtrace depth.
*
* @access public
* @since Log 1.12.7
*/
public function setBacktraceDepth($depth)
{
$this->_backtrace_depth = $depth;
}
/**
* Produces a formatted log line based on a format string and a set of
* variables representing the current log record and state.
......@@ -518,7 +542,9 @@ class Log
* variables (%5 %6,%7,%8), generate the backtrace and fetch them.
*/
if (preg_match('/%[5678]/', $format)) {
list($file, $line, $func, $class) = $this->_getBacktraceVars(2);
/* Plus 2 to account for our internal function calls. */
$d = $this->_backtrace_depth + 2;
list($file, $line, $func, $class) = $this->_getBacktraceVars($d);
}
/*
......
File moved
......@@ -2,7 +2,7 @@
/**
* $Header$
*
* @version $Revision: 224513 $
* @version $Revision: 306594 $
* @package Log
*/
......@@ -23,7 +23,14 @@ class Log_console extends Log
* @var resource
* @access private
*/
var $_stream = STDOUT;
var $_stream = null;
/**
* Is this object responsible for closing the stream resource?
* @var bool
* @access private
*/
var $_closeResource = false;
/**
* Should the output be buffered or displayed immediately?
......@@ -73,6 +80,11 @@ class Log_console extends Log
if (!empty($conf['stream'])) {
$this->_stream = $conf['stream'];
} elseif (defined('STDOUT')) {
$this->_stream = STDOUT;
} else {
$this->_stream = fopen('php://output', 'a');
$this->_closeResource = true;
}
if (isset($conf['buffering'])) {
......@@ -130,6 +142,9 @@ class Log_console extends Log
{
$this->flush();
$this->_opened = false;
if ($this->_closeResource === true && is_resource($this->_stream)) {
fclose($this->_stream);
}
return true;
}
......@@ -149,7 +164,7 @@ class Log_console extends Log
fwrite($this->_stream, $this->_buffer);
$this->_buffer = '';
}
if (is_resource($this->_stream)) {
return fflush($this->_stream);
}
......@@ -204,5 +219,4 @@ class Log_console extends Log
return true;
}
}
File moved
File moved
File moved
File moved
......@@ -2,7 +2,7 @@
/**
* $Header$
*
* @version $Revision: 306582 $
* @version $Revision: 313304 $
* @package Log
*/
......@@ -142,7 +142,7 @@ class Log_firebug extends Log
function flush() {
if (count($this->_buffer)) {
print '<script type="text/javascript">';
print "\nif (('console' in window) && ('firebug' in console)) {\n";
print "\nif ('console' in window) {\n";
foreach ($this->_buffer as $line) {
print " $line\n";
}
......@@ -193,7 +193,7 @@ class Log_firebug extends Log
$this->_buffer[] = sprintf('console.%s("%s");', $method, $line);
} else {
print '<script type="text/javascript">';
print "\nif (('console' in window) && ('firebug' in console)) {\n";
print "\nif ('console' in window) {\n";
/* Build and output the complete log line. */
printf(' console.%s("%s");', $method, $line);
print "\n}\n";
......
File moved
File moved
File moved
File moved
......@@ -3,7 +3,7 @@
* $Header$
* $Horde: horde/lib/Log/observer.php,v 1.5 2000/06/28 21:36:13 jon Exp $
*
* @version $Revision: 211953 $
* @version $Revision: 316951 $
* @package Log
*/
......@@ -78,7 +78,7 @@ class Log_observer
* instance.
*/
if (class_exists($class)) {
$object = &new $class($priority, $conf);
$object = new $class($priority, $conf);
return $object;
}
......@@ -102,9 +102,9 @@ class Log_observer
if (class_exists($class)) {
/* Support both new-style and old-style construction. */
if ($newstyle) {
$object = &new $class($priority, $conf);
$object = new $class($priority, $conf);
} else {
$object = &new $class($priority);
$object = new $class($priority);
}
return $object;
}
......
File moved
File moved
......@@ -3,7 +3,7 @@
* $Header$
* $Horde: horde/lib/Log/syslog.php,v 1.6 2000/06/28 21:36:13 jon Exp $
*
* @version $Revision: 302789 $
* @version $Revision: 308379 $
* @package Log
*/
......@@ -37,6 +37,13 @@ class Log_syslog extends Log
*/
var $_inherit = false;
/**
* Should we re-open the syslog connection for each log event?
* @var boolean
* @access private
*/
var $_reopen = false;
/**
* Maximum message length that will be sent to syslog(). If the handler
* receives a message longer than this length limit, it will be split into
......@@ -83,6 +90,9 @@ class Log_syslog extends Log
$this->_inherit = $conf['inherit'];
$this->_opened = $this->_inherit;
}
if (isset($conf['reopen'])) {
$this->_reopen = $conf['reopen'];
}
if (isset($conf['maxLength'])) {
$this->_maxLength = $conf['maxLength'];
}
......@@ -108,7 +118,7 @@ class Log_syslog extends Log
*/
function open()
{
if (!$this->_opened) {
if (!$this->_opened || $this->_reopen) {
$this->_opened = openlog($this->_ident, LOG_PID, $this->_name);
}
......@@ -154,8 +164,8 @@ class Log_syslog extends Log
return false;
}
/* If the connection isn't open and can't be opened, return failure. */
if (!$this->_opened && !$this->open()) {
/* If we need to (re)open the connection and open() fails, abort. */
if ((!$this->_opened || $this->_reopen) && !$this->open()) {
return false;
}
......
File moved
......@@ -8,8 +8,8 @@
:Author: Jon Parise
:Contact: jon@php.net
:Date: $Date: 2010-11-11 23:53:10 -0800 (Thu, 11 Nov 2010) $
:Revision: $Revision: 305290 $
:Date: $Date: 2011-02-15 21:13:19 -0800 (Tue, 15 Feb 2011) $
:Revision: $Revision: 308379 $
.. contents:: Contents
.. section-numbering::
......@@ -845,6 +845,10 @@ Configuration
| | | | process, or start a new |
| | | | one via `openlog()`_? |
+-------------------+-----------+---------------+---------------------------+
| ``reopen`` | Boolean | false | Reopen the syslog |
| | | | connection for each log |
| | | | event? |
+-------------------+-----------+---------------+---------------------------+
| ``maxLength`` | Integer | 500 | Maximum message length |
| | | | that will be sent to the |
| | | | `syslog()`_ function. |
......
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment