Inheritance: use trait Webiny\Component\StdLib\StdLibTrait, use trait Webiny\Component\StdLib\ComponentTrait
Example #1
0
 /**
  * @param string $format     The format of the message
  * @param string $dateFormat The format of the timestamp: one supported by DateTime::format
  *
  * @throws Exception\FileFormatterException
  */
 public function __construct($format = null, $dateFormat = null)
 {
     $this->config = Logger::getConfig()->get('Configs.Formatter.File');
     if ($this->isNull($this->config)) {
         throw new FileFormatterException(FileFormatterException::CONFIG_NOT_FOUND);
     }
     if ($this->isNull($format)) {
         $format = str_replace('\\n', "\n", $this->config->RecordFormat);
     }
     $this->format = $format;
     $this->dateFormat = $dateFormat !== null ? $dateFormat : $this->config->DateFormat;
 }
Example #2
0
 private function normalizeValue($data)
 {
     if ($this->isNull($data) || $this->isScalar($data)) {
         return $data;
     }
     if ($this->isStdObject($data)) {
         if ($this->isDateTimeObject($data)) {
             if ($this->isNull($this->config->DateFormat)) {
                 $format = Logger::getConfig()->Configs->Formatter->Default->DateFormat;
             } else {
                 $format = $this->config->DateFormat;
             }
             return $data->format($format);
         }
         $data = $data->val();
     }
     if ($this->isString($data)) {
         return $data;
     }
     if ($this->isArray($data) || $data instanceof \Traversable) {
         $normalized = array();
         foreach ($data as $key => $value) {
             $normalized[$key] = $this->normalizeValue($value);
         }
         return $normalized;
     }
     if ($this->isObject($data)) {
         if (method_exists($data, '___toString')) {
             return '' . $data;
         }
         return sprintf("[object] (%s: %s)", get_class($data), $this->jsonEncode($data));
     }
     if ($this->isResource($data)) {
         return '[resource]';
     }
     return '[unknown(' . gettype($data) . ')]';
 }
Example #3
0
 public function DriverSet()
 {
     Storage::setConfig(realpath(__DIR__ . '/' . self::CONFIG));
     Logger::setConfig(realpath(__DIR__ . '/' . self::CONFIG));
     return [[$this->logger('Webiny')]];
 }