PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/libs/pear/Log.php

http://github.com/ludovicchabant/PieCrust
PHP | 868 lines | 288 code | 67 blank | 513 comment | 29 complexity | c06c88931622a8b4a9b5a4373e5f9acc MD5 | raw file
Possible License(s): Apache-2.0, GPL-3.0, BSD-3-Clause
  1. <?php
  2. /**
  3. * $Header$
  4. * $Horde: horde/lib/Log.php,v 1.15 2000/06/29 23:39:45 jon Exp $
  5. *
  6. * @version $Revision: 310238 $
  7. * @package Log
  8. */
  9. define('PEAR_LOG_EMERG', 0); /* System is unusable */
  10. define('PEAR_LOG_ALERT', 1); /* Immediate action required */
  11. define('PEAR_LOG_CRIT', 2); /* Critical conditions */
  12. define('PEAR_LOG_ERR', 3); /* Error conditions */
  13. define('PEAR_LOG_WARNING', 4); /* Warning conditions */
  14. define('PEAR_LOG_NOTICE', 5); /* Normal but significant */
  15. define('PEAR_LOG_INFO', 6); /* Informational */
  16. define('PEAR_LOG_DEBUG', 7); /* Debug-level messages */
  17. define('PEAR_LOG_ALL', 0xffffffff); /* All messages */
  18. define('PEAR_LOG_NONE', 0x00000000); /* No message */
  19. /* Log types for PHP's native error_log() function. */
  20. define('PEAR_LOG_TYPE_SYSTEM', 0); /* Use PHP's system logger */
  21. define('PEAR_LOG_TYPE_MAIL', 1); /* Use PHP's mail() function */
  22. define('PEAR_LOG_TYPE_DEBUG', 2); /* Use PHP's debugging connection */
  23. define('PEAR_LOG_TYPE_FILE', 3); /* Append to a file */
  24. define('PEAR_LOG_TYPE_SAPI', 4); /* Use the SAPI logging handler */
  25. /**
  26. * The Log:: class implements both an abstraction for various logging
  27. * mechanisms and the Subject end of a Subject-Observer pattern.
  28. *
  29. * @author Chuck Hagenbuch <chuck@horde.org>
  30. * @author Jon Parise <jon@php.net>
  31. * @since Horde 1.3
  32. * @package Log
  33. */
  34. class Log
  35. {
  36. /**
  37. * Indicates whether or not the log can been opened / connected.
  38. *
  39. * @var boolean
  40. * @access protected
  41. */
  42. var $_opened = false;
  43. /**
  44. * Instance-specific unique identification number.
  45. *
  46. * @var integer
  47. * @access protected
  48. */
  49. var $_id = 0;
  50. /**
  51. * The label that uniquely identifies this set of log messages.
  52. *
  53. * @var string
  54. * @access protected
  55. */
  56. var $_ident = '';
  57. /**
  58. * The default priority to use when logging an event.
  59. *
  60. * @var integer
  61. * @access protected
  62. */
  63. var $_priority = PEAR_LOG_INFO;
  64. /**
  65. * The bitmask of allowed log levels.
  66. *
  67. * @var integer
  68. * @access protected
  69. */
  70. var $_mask = PEAR_LOG_ALL;
  71. /**
  72. * Holds all Log_observer objects that wish to be notified of new messages.
  73. *
  74. * @var array
  75. * @access protected
  76. */
  77. var $_listeners = array();
  78. /**
  79. * Starting depth to use when walking a backtrace in search of the
  80. * function that invoked the log system.
  81. *
  82. * @var integer
  83. * @access protected
  84. */
  85. var $_backtrace_depth = 0;
  86. /**
  87. * Maps canonical format keys to position arguments for use in building
  88. * "line format" strings.
  89. *
  90. * @var array
  91. * @access protected
  92. */
  93. var $_formatMap = array('%{timestamp}' => '%1$s',
  94. '%{ident}' => '%2$s',
  95. '%{priority}' => '%3$s',
  96. '%{message}' => '%4$s',
  97. '%{file}' => '%5$s',
  98. '%{line}' => '%6$s',
  99. '%{function}' => '%7$s',
  100. '%{class}' => '%8$s',
  101. '%\{' => '%%{');
  102. /**
  103. * Attempts to return a concrete Log instance of type $handler.
  104. *
  105. * @param string $handler The type of concrete Log subclass to return.
  106. * Attempt to dynamically include the code for
  107. * this subclass. Currently, valid values are
  108. * 'console', 'syslog', 'sql', 'file', and 'mcal'.
  109. *
  110. * @param string $name The name of the actually log file, table, or
  111. * other specific store to use. Defaults to an
  112. * empty string, with which the subclass will
  113. * attempt to do something intelligent.
  114. *
  115. * @param string $ident The identity reported to the log system.
  116. *
  117. * @param array $conf A hash containing any additional configuration
  118. * information that a subclass might need.
  119. *
  120. * @param int $level Log messages up to and including this level.
  121. *
  122. * @return object Log The newly created concrete Log instance, or
  123. * null on an error.
  124. * @access public
  125. * @since Log 1.0
  126. */
  127. public static function factory($handler, $name = '', $ident = '',
  128. $conf = array(), $level = PEAR_LOG_DEBUG)
  129. {
  130. $handler = strtolower($handler);
  131. $class = 'Log_' . $handler;
  132. $classfile = 'Log/' . $handler . '.php';
  133. /*
  134. * Attempt to include our version of the named class, but don't treat
  135. * a failure as fatal. The caller may have already included their own
  136. * version of the named class.
  137. */
  138. if (!class_exists($class, false)) {
  139. include_once $classfile;
  140. }
  141. /* If the class exists, return a new instance of it. */
  142. if (class_exists($class, false)) {
  143. $obj = new $class($name, $ident, $conf, $level);
  144. return $obj;
  145. }
  146. $null = null;
  147. return $null;
  148. }
  149. /**
  150. * Attempts to return a reference to a concrete Log instance of type
  151. * $handler, only creating a new instance if no log instance with the same
  152. * parameters currently exists.
  153. *
  154. * You should use this if there are multiple places you might create a
  155. * logger, you don't want to create multiple loggers, and you don't want to
  156. * check for the existance of one each time. The singleton pattern does all
  157. * the checking work for you.
  158. *
  159. * <b>You MUST call this method with the $var = &Log::singleton() syntax.
  160. * Without the ampersand (&) in front of the method name, you will not get
  161. * a reference, you will get a copy.</b>
  162. *
  163. * @param string $handler The type of concrete Log subclass to return.
  164. * Attempt to dynamically include the code for
  165. * this subclass. Currently, valid values are
  166. * 'console', 'syslog', 'sql', 'file', and 'mcal'.
  167. *
  168. * @param string $name The name of the actually log file, table, or
  169. * other specific store to use. Defaults to an
  170. * empty string, with which the subclass will
  171. * attempt to do something intelligent.
  172. *
  173. * @param string $ident The identity reported to the log system.
  174. *
  175. * @param array $conf A hash containing any additional configuration
  176. * information that a subclass might need.
  177. *
  178. * @param int $level Log messages up to and including this level.
  179. *
  180. * @return object Log The newly created concrete Log instance, or
  181. * null on an error.
  182. * @access public
  183. * @since Log 1.0
  184. */
  185. public static function singleton($handler, $name = '', $ident = '',
  186. $conf = array(), $level = PEAR_LOG_DEBUG)
  187. {
  188. static $instances;
  189. if (!isset($instances)) $instances = array();
  190. $signature = serialize(array($handler, $name, $ident, $conf, $level));
  191. if (!isset($instances[$signature])) {
  192. $instances[$signature] = Log::factory($handler, $name, $ident,
  193. $conf, $level);
  194. }
  195. return $instances[$signature];
  196. }
  197. /**
  198. * Abstract implementation of the open() method.
  199. * @since Log 1.0
  200. */
  201. function open()
  202. {
  203. return false;
  204. }
  205. /**
  206. * Abstract implementation of the close() method.
  207. * @since Log 1.0
  208. */
  209. function close()
  210. {
  211. return false;
  212. }
  213. /**
  214. * Abstract implementation of the flush() method.
  215. * @since Log 1.8.2
  216. */
  217. function flush()
  218. {
  219. return false;
  220. }
  221. /**
  222. * Abstract implementation of the log() method.
  223. * @since Log 1.0
  224. */
  225. function log($message, $priority = null)
  226. {
  227. return false;
  228. }
  229. /**
  230. * A convenience function for logging a emergency event. It will log a
  231. * message at the PEAR_LOG_EMERG log level.
  232. *
  233. * @param mixed $message String or object containing the message
  234. * to log.
  235. *
  236. * @return boolean True if the message was successfully logged.
  237. *
  238. * @access public
  239. * @since Log 1.7.0
  240. */
  241. function emerg($message)
  242. {
  243. return $this->log($message, PEAR_LOG_EMERG);
  244. }
  245. /**
  246. * A convenience function for logging an alert event. It will log a
  247. * message at the PEAR_LOG_ALERT log level.
  248. *
  249. * @param mixed $message String or object containing the message
  250. * to log.
  251. *
  252. * @return boolean True if the message was successfully logged.
  253. *
  254. * @access public
  255. * @since Log 1.7.0
  256. */
  257. function alert($message)
  258. {
  259. return $this->log($message, PEAR_LOG_ALERT);
  260. }
  261. /**
  262. * A convenience function for logging a critical event. It will log a
  263. * message at the PEAR_LOG_CRIT log level.
  264. *
  265. * @param mixed $message String or object containing the message
  266. * to log.
  267. *
  268. * @return boolean True if the message was successfully logged.
  269. *
  270. * @access public
  271. * @since Log 1.7.0
  272. */
  273. function crit($message)
  274. {
  275. return $this->log($message, PEAR_LOG_CRIT);
  276. }
  277. /**
  278. * A convenience function for logging a error event. It will log a
  279. * message at the PEAR_LOG_ERR log level.
  280. *
  281. * @param mixed $message String or object containing the message
  282. * to log.
  283. *
  284. * @return boolean True if the message was successfully logged.
  285. *
  286. * @access public
  287. * @since Log 1.7.0
  288. */
  289. function err($message)
  290. {
  291. return $this->log($message, PEAR_LOG_ERR);
  292. }
  293. /**
  294. * A convenience function for logging a warning event. It will log a
  295. * message at the PEAR_LOG_WARNING log level.
  296. *
  297. * @param mixed $message String or object containing the message
  298. * to log.
  299. *
  300. * @return boolean True if the message was successfully logged.
  301. *
  302. * @access public
  303. * @since Log 1.7.0
  304. */
  305. function warning($message)
  306. {
  307. return $this->log($message, PEAR_LOG_WARNING);
  308. }
  309. /**
  310. * A convenience function for logging a notice event. It will log a
  311. * message at the PEAR_LOG_NOTICE log level.
  312. *
  313. * @param mixed $message String or object containing the message
  314. * to log.
  315. *
  316. * @return boolean True if the message was successfully logged.
  317. *
  318. * @access public
  319. * @since Log 1.7.0
  320. */
  321. function notice($message)
  322. {
  323. return $this->log($message, PEAR_LOG_NOTICE);
  324. }
  325. /**
  326. * A convenience function for logging a information event. It will log a
  327. * message at the PEAR_LOG_INFO log level.
  328. *
  329. * @param mixed $message String or object containing the message
  330. * to log.
  331. *
  332. * @return boolean True if the message was successfully logged.
  333. *
  334. * @access public
  335. * @since Log 1.7.0
  336. */
  337. function info($message)
  338. {
  339. return $this->log($message, PEAR_LOG_INFO);
  340. }
  341. /**
  342. * A convenience function for logging a debug event. It will log a
  343. * message at the PEAR_LOG_DEBUG log level.
  344. *
  345. * @param mixed $message String or object containing the message
  346. * to log.
  347. *
  348. * @return boolean True if the message was successfully logged.
  349. *
  350. * @access public
  351. * @since Log 1.7.0
  352. */
  353. function debug($message)
  354. {
  355. return $this->log($message, PEAR_LOG_DEBUG);
  356. }
  357. /**
  358. * Returns the string representation of the message data.
  359. *
  360. * If $message is an object, _extractMessage() will attempt to extract
  361. * the message text using a known method (such as a PEAR_Error object's
  362. * getMessage() method). If a known method, cannot be found, the
  363. * serialized representation of the object will be returned.
  364. *
  365. * If the message data is already a string, it will be returned unchanged.
  366. *
  367. * @param mixed $message The original message data. This may be a
  368. * string or any object.
  369. *
  370. * @return string The string representation of the message.
  371. *
  372. * @access protected
  373. */
  374. function _extractMessage($message)
  375. {
  376. /*
  377. * If we've been given an object, attempt to extract the message using
  378. * a known method. If we can't find such a method, default to the
  379. * "human-readable" version of the object.
  380. *
  381. * We also use the human-readable format for arrays.
  382. */
  383. if (is_object($message)) {
  384. if (method_exists($message, 'getmessage')) {
  385. $message = $message->getMessage();
  386. } else if (method_exists($message, 'tostring')) {
  387. $message = $message->toString();
  388. } else if (method_exists($message, '__tostring')) {
  389. $message = (string)$message;
  390. } else {
  391. $message = var_export($message, true);
  392. }
  393. } else if (is_array($message)) {
  394. if (isset($message['message'])) {
  395. if (is_scalar($message['message'])) {
  396. $message = $message['message'];
  397. } else {
  398. $message = var_export($message['message'], true);
  399. }
  400. } else {
  401. $message = var_export($message, true);
  402. }
  403. } else if (is_bool($message) || $message === NULL) {
  404. $message = var_export($message, true);
  405. }
  406. /* Otherwise, we assume the message is a string. */
  407. return $message;
  408. }
  409. /**
  410. * Using debug_backtrace(), returns the file, line, and enclosing function
  411. * name of the source code context from which log() was invoked.
  412. *
  413. * @param int $depth The initial number of frames we should step
  414. * back into the trace.
  415. *
  416. * @return array Array containing four strings: the filename, the line,
  417. * the function name, and the class name from which log()
  418. * was called.
  419. *
  420. * @access private
  421. * @since Log 1.9.4
  422. */
  423. function _getBacktraceVars($depth)
  424. {
  425. /* Start by generating a backtrace from the current call (here). */
  426. $bt = debug_backtrace();
  427. /* Store some handy shortcuts to our previous frames. */
  428. $bt0 = isset($bt[$depth]) ? $bt[$depth] : null;
  429. $bt1 = isset($bt[$depth + 1]) ? $bt[$depth + 1] : null;
  430. /*
  431. * If we were ultimately invoked by the composite handler, we need to
  432. * increase our depth one additional level to compensate.
  433. */
  434. $class = isset($bt1['class']) ? $bt1['class'] : null;
  435. if ($class !== null && strcasecmp($class, 'Log_composite') == 0) {
  436. $depth++;
  437. $bt0 = isset($bt[$depth]) ? $bt[$depth] : null;
  438. $bt1 = isset($bt[$depth + 1]) ? $bt[$depth + 1] : null;
  439. $class = isset($bt1['class']) ? $bt1['class'] : null;
  440. }
  441. /*
  442. * We're interested in the frame which invoked the log() function, so
  443. * we need to walk back some number of frames into the backtrace. The
  444. * $depth parameter tells us where to start looking. We go one step
  445. * further back to find the name of the encapsulating function from
  446. * which log() was called.
  447. */
  448. $file = isset($bt0) ? $bt0['file'] : null;
  449. $line = isset($bt0) ? $bt0['line'] : 0;
  450. $func = isset($bt1) ? $bt1['function'] : null;
  451. /*
  452. * However, if log() was called from one of our "shortcut" functions,
  453. * we're going to need to go back an additional step.
  454. */
  455. if (in_array($func, array('emerg', 'alert', 'crit', 'err', 'warning',
  456. 'notice', 'info', 'debug'))) {
  457. $bt2 = isset($bt[$depth + 2]) ? $bt[$depth + 2] : null;
  458. $file = is_array($bt1) ? $bt1['file'] : null;
  459. $line = is_array($bt1) ? $bt1['line'] : 0;
  460. $func = is_array($bt2) ? $bt2['function'] : null;
  461. $class = isset($bt2['class']) ? $bt2['class'] : null;
  462. }
  463. /*
  464. * If we couldn't extract a function name (perhaps because we were
  465. * executed from the "main" context), provide a default value.
  466. */
  467. if ($func === null) {
  468. $func = '(none)';
  469. }
  470. /* Return a 4-tuple containing (file, line, function, class). */
  471. return array($file, $line, $func, $class);
  472. }
  473. /**
  474. * Sets the starting depth to use when walking a backtrace in search of
  475. * the function that invoked the log system. This is used on conjunction
  476. * with the 'file', 'line', 'function', and 'class' formatters.
  477. *
  478. * @param int $depth The new backtrace depth.
  479. *
  480. * @access public
  481. * @since Log 1.12.7
  482. */
  483. public function setBacktraceDepth($depth)
  484. {
  485. $this->_backtrace_depth = $depth;
  486. }
  487. /**
  488. * Produces a formatted log line based on a format string and a set of
  489. * variables representing the current log record and state.
  490. *
  491. * @return string Formatted log string.
  492. *
  493. * @access protected
  494. * @since Log 1.9.4
  495. */
  496. function _format($format, $timestamp, $priority, $message)
  497. {
  498. /*
  499. * If the format string references any of the backtrace-driven
  500. * variables (%5 %6,%7,%8), generate the backtrace and fetch them.
  501. */
  502. if (preg_match('/%[5678]/', $format)) {
  503. /* Plus 2 to account for our internal function calls. */
  504. $d = $this->_backtrace_depth + 2;
  505. list($file, $line, $func, $class) = $this->_getBacktraceVars($d);
  506. }
  507. /*
  508. * Build the formatted string. We use the sprintf() function's
  509. * "argument swapping" capability to dynamically select and position
  510. * the variables which will ultimately appear in the log string.
  511. */
  512. return sprintf($format,
  513. $timestamp,
  514. $this->_ident,
  515. $this->priorityToString($priority),
  516. $message,
  517. isset($file) ? $file : '',
  518. isset($line) ? $line : '',
  519. isset($func) ? $func : '',
  520. isset($class) ? $class : '');
  521. }
  522. /**
  523. * Returns the string representation of a PEAR_LOG_* integer constant.
  524. *
  525. * @param int $priority A PEAR_LOG_* integer constant.
  526. *
  527. * @return string The string representation of $level.
  528. *
  529. * @access public
  530. * @since Log 1.0
  531. */
  532. function priorityToString($priority)
  533. {
  534. $levels = array(
  535. PEAR_LOG_EMERG => 'emergency',
  536. PEAR_LOG_ALERT => 'alert',
  537. PEAR_LOG_CRIT => 'critical',
  538. PEAR_LOG_ERR => 'error',
  539. PEAR_LOG_WARNING => 'warning',
  540. PEAR_LOG_NOTICE => 'notice',
  541. PEAR_LOG_INFO => 'info',
  542. PEAR_LOG_DEBUG => 'debug'
  543. );
  544. return $levels[$priority];
  545. }
  546. /**
  547. * Returns the the PEAR_LOG_* integer constant for the given string
  548. * representation of a priority name. This function performs a
  549. * case-insensitive search.
  550. *
  551. * @param string $name String containing a priority name.
  552. *
  553. * @return string The PEAR_LOG_* integer contstant corresponding
  554. * the the specified priority name.
  555. *
  556. * @access public
  557. * @since Log 1.9.0
  558. */
  559. function stringToPriority($name)
  560. {
  561. $levels = array(
  562. 'emergency' => PEAR_LOG_EMERG,
  563. 'alert' => PEAR_LOG_ALERT,
  564. 'critical' => PEAR_LOG_CRIT,
  565. 'error' => PEAR_LOG_ERR,
  566. 'warning' => PEAR_LOG_WARNING,
  567. 'notice' => PEAR_LOG_NOTICE,
  568. 'info' => PEAR_LOG_INFO,
  569. 'debug' => PEAR_LOG_DEBUG
  570. );
  571. return $levels[strtolower($name)];
  572. }
  573. /**
  574. * Calculate the log mask for the given priority.
  575. *
  576. * This method may be called statically.
  577. *
  578. * @param integer $priority The priority whose mask will be calculated.
  579. *
  580. * @return integer The calculated log mask.
  581. *
  582. * @access public
  583. * @since Log 1.7.0
  584. */
  585. public static function MASK($priority)
  586. {
  587. return (1 << $priority);
  588. }
  589. /**
  590. * Calculate the log mask for all priorities up to the given priority.
  591. *
  592. * This method may be called statically.
  593. *
  594. * @param integer $priority The maximum priority covered by this mask.
  595. *
  596. * @return integer The resulting log mask.
  597. *
  598. * @access public
  599. * @since Log 1.7.0
  600. *
  601. * @deprecated deprecated since Log 1.9.4; use Log::MAX() instead
  602. */
  603. public static function UPTO($priority)
  604. {
  605. return Log::MAX($priority);
  606. }
  607. /**
  608. * Calculate the log mask for all priorities greater than or equal to the
  609. * given priority. In other words, $priority will be the lowest priority
  610. * matched by the resulting mask.
  611. *
  612. * This method may be called statically.
  613. *
  614. * @param integer $priority The minimum priority covered by this mask.
  615. *
  616. * @return integer The resulting log mask.
  617. *
  618. * @access public
  619. * @since Log 1.9.4
  620. */
  621. public static function MIN($priority)
  622. {
  623. return PEAR_LOG_ALL ^ ((1 << $priority) - 1);
  624. }
  625. /**
  626. * Calculate the log mask for all priorities less than or equal to the
  627. * given priority. In other words, $priority will be the highests priority
  628. * matched by the resulting mask.
  629. *
  630. * This method may be called statically.
  631. *
  632. * @param integer $priority The maximum priority covered by this mask.
  633. *
  634. * @return integer The resulting log mask.
  635. *
  636. * @access public
  637. * @since Log 1.9.4
  638. */
  639. public static function MAX($priority)
  640. {
  641. return ((1 << ($priority + 1)) - 1);
  642. }
  643. /**
  644. * Set and return the level mask for the current Log instance.
  645. *
  646. * @param integer $mask A bitwise mask of log levels.
  647. *
  648. * @return integer The current level mask.
  649. *
  650. * @access public
  651. * @since Log 1.7.0
  652. */
  653. function setMask($mask)
  654. {
  655. $this->_mask = $mask;
  656. return $this->_mask;
  657. }
  658. /**
  659. * Returns the current level mask.
  660. *
  661. * @return interger The current level mask.
  662. *
  663. * @access public
  664. * @since Log 1.7.0
  665. */
  666. function getMask()
  667. {
  668. return $this->_mask;
  669. }
  670. /**
  671. * Check if the given priority is included in the current level mask.
  672. *
  673. * @param integer $priority The priority to check.
  674. *
  675. * @return boolean True if the given priority is included in the current
  676. * log mask.
  677. *
  678. * @access protected
  679. * @since Log 1.7.0
  680. */
  681. function _isMasked($priority)
  682. {
  683. return (Log::MASK($priority) & $this->_mask);
  684. }
  685. /**
  686. * Returns the current default priority.
  687. *
  688. * @return integer The current default priority.
  689. *
  690. * @access public
  691. * @since Log 1.8.4
  692. */
  693. function getPriority()
  694. {
  695. return $this->_priority;
  696. }
  697. /**
  698. * Sets the default priority to the specified value.
  699. *
  700. * @param integer $priority The new default priority.
  701. *
  702. * @access public
  703. * @since Log 1.8.4
  704. */
  705. function setPriority($priority)
  706. {
  707. $this->_priority = $priority;
  708. }
  709. /**
  710. * Adds a Log_observer instance to the list of observers that are listening
  711. * for messages emitted by this Log instance.
  712. *
  713. * @param object $observer The Log_observer instance to attach as a
  714. * listener.
  715. *
  716. * @param boolean True if the observer is successfully attached.
  717. *
  718. * @access public
  719. * @since Log 1.0
  720. */
  721. function attach(&$observer)
  722. {
  723. if (!is_a($observer, 'Log_observer')) {
  724. return false;
  725. }
  726. $this->_listeners[$observer->_id] = &$observer;
  727. return true;
  728. }
  729. /**
  730. * Removes a Log_observer instance from the list of observers.
  731. *
  732. * @param object $observer The Log_observer instance to detach from
  733. * the list of listeners.
  734. *
  735. * @param boolean True if the observer is successfully detached.
  736. *
  737. * @access public
  738. * @since Log 1.0
  739. */
  740. function detach($observer)
  741. {
  742. if (!is_a($observer, 'Log_observer') ||
  743. !isset($this->_listeners[$observer->_id])) {
  744. return false;
  745. }
  746. unset($this->_listeners[$observer->_id]);
  747. return true;
  748. }
  749. /**
  750. * Informs each registered observer instance that a new message has been
  751. * logged.
  752. *
  753. * @param array $event A hash describing the log event.
  754. *
  755. * @access protected
  756. */
  757. function _announce($event)
  758. {
  759. foreach ($this->_listeners as $id => $listener) {
  760. if ($event['priority'] <= $this->_listeners[$id]->_priority) {
  761. $this->_listeners[$id]->notify($event);
  762. }
  763. }
  764. }
  765. /**
  766. * Indicates whether this is a composite class.
  767. *
  768. * @return boolean True if this is a composite class.
  769. *
  770. * @access public
  771. * @since Log 1.0
  772. */
  773. function isComposite()
  774. {
  775. return false;
  776. }
  777. /**
  778. * Sets this Log instance's identification string.
  779. *
  780. * @param string $ident The new identification string.
  781. *
  782. * @access public
  783. * @since Log 1.6.3
  784. */
  785. function setIdent($ident)
  786. {
  787. $this->_ident = $ident;
  788. }
  789. /**
  790. * Returns the current identification string.
  791. *
  792. * @return string The current Log instance's identification string.
  793. *
  794. * @access public
  795. * @since Log 1.6.3
  796. */
  797. function getIdent()
  798. {
  799. return $this->_ident;
  800. }
  801. }