Source for file logging.php

Documentation is available at logging.php

  1. <?php
  2. /**
  3. * Flat file logging of Bumblebee events
  4. *
  5. * @author    Stuart Prescott
  6. * @copyright  Copyright Stuart Prescott
  7. * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  8. * @version    $Id$
  9. * @package    Bumblebee
  10. * @subpackage Misc
  11. */
  12.  
  13. /** Load ancillary functions */
  14. require_once 'inc/typeinfo.php';
  15.  
  16. require_once 'inc/bb/configreader.php';
  17.  
  18. function logmsg($priority, $message) {
  19.   global $auth, $action;
  20.   $conf = ConfigReader::getInstance();
  21.   if (! $conf->value('error_handling', 'UseLogFile') ||
  22.       $priority >= $conf->value('error_handling', 'LogLevel')) return;
  23.  
  24.   // Log line format:
  25.   // IP username (uid) [DD/Mon/YYYY:HH:MM:SS TZ] "action" "Message"\n
  26.  
  27.   $date     = gmdate("d/M/Y:H:i:s O");
  28.   $ip       = is_object($auth)   ? $auth->getRemoteIP() : '-';
  29.   $username = is_object($auth)   ? $auth->username      : '-';
  30.   $uid      = is_object($auth)   ? $auth->uid           : '-';
  31.   $verb     = is_object($action) ? $action->_verb       : '-';
  32.  
  33.   $logstring = "$ip $username ($uid) [$date] \"$verb\" \"$message\"\n";
  34.  
  35.   error_log($logstring, 3, $conf->value('error_handling', 'LogFile'));
  36. }
  37. ?>

Documentation generated on Tue, 06 Mar 2007 10:01:44 +0000 by phpDocumentor 1.3.0