Ejemplo n.º 1
0
 public function log($level, $message, array $context = array())
 {
     $interpolated_message = Manipulation::interpolate($message, $context);
     $interpolated_message = trim($interpolated_message, "\n");
     //return value isn't documentated because it MUST NOT be used/trusted
     return $this->stream ? fwrite($this->stream, '[' . $level . '] ' . $interpolated_message . "\n") : null;
 }
Ejemplo n.º 2
0
 public static function getValueFromEnvironment(array $collection)
 {
     foreach ($collection as &$value) {
         //check for sobstitution
         if (is_string($value) && (strpos($value, '{{@') === 0 && strpos($value, '}}') !== false)) {
             if (($toReplace = Manipulation::getBetween($value, '{{@', '}}')) != '') {
                 $value = getenv($toReplace);
                 if ($value !== false) {
                     $value = $value;
                 } elseif (defined($toReplace)) {
                     $value = constant($toReplace);
                 }
             }
         } elseif (is_array($value)) {
             $value = self::getValueFromEnvironment($value);
         } elseif ($value instanceof GenericCollection) {
             $value = self::getValueFromEnvironment($value->all());
         }
     }
     return $collection;
 }
Ejemplo n.º 3
0
 public function log($level, $message, array $context = array())
 {
     $interpolated_message = Manipulation::interpolate($message, $context);
     //get the urgency level:
     $syslog_level = LOG_EMERG;
     switch ($level) {
         case LogLevel::EMERGENCY:
             $syslog_level = LOG_EMERG;
             break;
         case LogLevel::ALERT:
             $syslog_level = LOG_ALERT;
             break;
         case LogLevel::CRITICAL:
             $syslog_level = LOG_CRIT;
             break;
         case LogLevel::ERROR:
             $syslog_level = LOG_ERR;
             break;
         case LogLevel::WARNING:
             $syslog_level = LOG_WARNING;
             break;
         case LogLevel::NOTICE:
             $syslog_level = LOG_NOTICE;
             break;
         case LogLevel::INFO:
             $syslog_level = LOG_INFO;
             break;
         default:
             $syslog_level = LOG_DEBUG;
     }
     if (openlog($this->identity, LOG_NDELAY | LOG_PID, LOG_USER)) {
         //save the log using the UNIX standard logging ultility
         syslog($this->GetLevel(), $interpolated_message);
         //virtually close the connection to syslogd
         closelog();
     }
 }
Ejemplo n.º 4
0
 /**
  * build a regex out of the URI of the current Route and adds name of
  * regex placeholders.
  * 
  * Example:
  * <code>
  * array(
  *     "regex"  => "...",
  *     "params" => array("name", "surname")
  * )
  * </code>
  * 
  * __Note:__ if the regex field of the returned array is an empty string,
  * then the router is a special callback
  * 
  * @return array the regex version of the URI and additional info
  */
 public function getRegex()
 {
     //fix the URI
     $regexURI = null;
     $paramArray = [];
     $paramSkip = [];
     $paramTypes = [];
     if ($this->isSpecialCallback() === false) {
         //start building the regex
         $regexURI = '/^' . preg_quote($this->URI, '/') . '$/';
         //this will contain the matched expressions placeholders
         $params = [];
         //detect if regex are involved in the furnished URI
         if (preg_match_all("/\\\\{([a-zA-Z]|\\d|\\_|\\.|\\:|\\\\)+\\\\}/", $regexURI, $params)) {
             //substitute a regex for each matching group:
             foreach ($params[0] as $mathingGroup) {
                 //extract the regex to be used
                 $param = Manipulation::getBetween($mathingGroup, '\\{', '\\}');
                 $regexId = explode('\\:', $param, 2);
                 $currentRegex = '';
                 if (count($regexId) == 2) {
                     $currentRegex = strval($regexId[1]);
                 }
                 $param = $regexId[0];
                 $regexTableId = 'default';
                 switch (strtolower($currentRegex)) {
                     case 'mail':
                     case 'email':
                         $regexTableId = 'email';
                         break;
                     case 'number':
                     case 'integer':
                     case 'signed_integer':
                         $regexTableId = 'signed_integer';
                         break;
                     default:
                         $regexTableId = 'default';
                 }
                 $regexURI = str_replace($mathingGroup, '(' . self::$regexTable[$regexTableId][0] . ')', $regexURI);
                 $paramArray[] = $param;
                 $paramTypes[] = $regexTableId;
                 $paramSkip[] = self::$regexTable[$regexTableId][1];
             }
         }
     }
     //return the built regex + additionals info
     return ['regex' => !is_null($regexURI) ? $regexURI : '', 'params' => $paramArray, 'param_types' => $paramTypes, 'skipping_params' => $paramSkip];
 }
Ejemplo n.º 5
0
 public function log($level, $message, array $context = array())
 {
     $interpolated_message = Manipulation::interpolate($message, $context);
     $interpolated_message = trim($interpolated_message);
     return $this->handler ? fwrite($this->handler, '[' . $level . '] ' . $interpolated_message . "\n") : null;
 }