Example #1
0
 /**
  * Initializes the logging
  *
  * @access public
  * @return boolean
  */
 public static function Initialize()
 {
     if (defined('LOG_SYSLOG_HOST')) {
         self::$hostname = LOG_SYSLOG_HOST;
     }
     if (defined('LOG_SYSLOG_PORT')) {
         self::$port = LOG_SYSLOG_PORT;
     }
     if (defined('LOG_SYSLOG_PROGRAM')) {
         self::$program = LOG_SYSLOG_PROGRAM;
     }
 }
Example #2
0
 /**
  * Write the message to the log facility.
  *
  * @param int       $loglevel
  * @param string    $data
  * @param string    $logfile
  *
  * @access private
  * @return void
  */
 private static function writeToLog($loglevel, $data, $logfile = null)
 {
     if (self::$syslogEnabled) {
         if (ZSyslog::send($loglevel, $data) === false) {
             error_log("Unable to send to syslog");
             error_log($data);
         }
     } else {
         if (@file_put_contents($logfile, $data, FILE_APPEND) === false) {
             error_log(sprintf("Unable to write in %s", $logfile));
             error_log($data);
         }
     }
 }