/** * @inheritDoc */ public function handle(EventInterface $event) { if ($event instanceof BeforeRouteEvent) { $fff = self::fff(); self::dispatchEvent(new LogEvent(LoggerLevelEnum::INFO(), LoggerTemplate::LOGGER_MESSAGE_REQUEST_INFO, ['verb' => $fff->get('VERB'), 'pattern' => $fff->get('PATTERN'), 'uri' => $fff->get('URI'), 'body' => Utility::instance()->convertUnicodeToUTF8($fff->get('BODY'))])); } }
/** * @inheritDoc */ public function handle(EventInterface $event) { if ($event instanceof LogEvent) { //! get the default logger $logger = Utility::instance()->getLogger(); if (!is_null($logger)) { call_user_func_array([$logger, $event->getLevel()], [$event->getMessage(), $event->getContext()]); } } }
/** * @inheritDoc */ public function handle(EventInterface $event) { if ($event instanceof MissingCallbackEvent) { $fff = self::fff(); //! log self::dispatchEvent(new LogEvent(LoggerLevelEnum::ERROR(), LoggerTemplate::LOGGER_MESSAGE_JSONP_MISSING_CALLBACK, ['callback' => Utility::instance()->jsonpCallback(), 'verb' => $fff->get('VERB'), 'uri' => $fff->get('URI')])); //! error self::dispatchEvent(new ErrorEvent(ErrorEnum::ERROR500())); } }
public static function filename() { return sprintf('%1$s-%2$s', self::LOGGER_FILENAME, Web::instance()->slug(Utility::date(self::LOGGER_FILENAME_DATE_FORMAT))); }
ini_set('xdebug.var_display_max_depth', 10); ini_set('xdebug.var_display_max_children', 256); ini_set('xdebug.var_display_max_data', 1024); require_once '../../../vendor/autoload.php'; use FrancisDesjardins\WebService\Rest\Responder\Encoder\NoopResponderEncoder; use FrancisDesjardins\WebService\Rest\Responder\ErrorResponder; use FrancisDesjardins\WebService\Rest\Utility; /** @var Base $fw */ $fw = Base::instance(); //! load globals $fw->config('../app/globals.ini'); //! load globals (OS specific) if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $fw->config('../app/globals.windows.ini'); } else { $fw->config('../app/globals.linux.ini'); } //! load custom sections $fw->config('../app/custom.ini'); //! load mappings $fw->config('../app/maps.ini'); //! global error handler if (!Utility::instance()->debug()) { $fw->set('ONERROR', function (Base $fw) { Utility::instance()->flushOutputBuffer(); $responder = new ErrorResponder($fw); $responder->respond(new NoopResponderEncoder()); }); } //! run it! $fw->run();
/** * Recursively clear existing output buffer */ private function flushOutputBuffer() { //! in production we flush any buffered output if (!Utility::instance()->debug()) { Utility::instance()->flushOutputBuffer(); } }
/** * Returns the content-type header string * @return string */ public function header() { return sprintf(self::HEADER_CONTENT_TYPE_TEMPLATE, self::CONTENT_TYPE, Utility::instance()->encoding()); }