Get logs from Log service.
Unsuccessful operation will cause an Exception.

@param GetLogsRequest $request the GetLogs request parameters class.

@throws Exception
@return GetLogsResponse
11922
public function getLogs(GetLogsRequest $request)
    {
        $headers = array();
        $params  = array();
        if ($request->getTopic() !== null) {
            $params ['topic'] = $request->getTopic();
        }
        if ($request->getFrom() !== null) {
            $params ['from'] = $request->getFrom();
        }
        if ($request->getTo() !== null) {
            $params ['to'] = $request->getTo();
        }
        if ($request->getQuery() !== null) {
            $params ['query'] = $request->getQuery();
        }
        $params ['type'] = 'log';
        if ($request->getLine() !== null) {
            $params ['line'] = $request->getLine();
        }
        if ($request->getOffset() !== null) {
            $params ['offset'] = $request->getOffset();
        }
        if ($request->getOffset() !== null) {
            $params ['reverse'] = $request->getReverse() ? 'true' : 'false';
        }

        $project  = $request->getProject() ?: '';
        $logStore = $request->getLogStore() ?: '';

        $resource = "/logstores/$logStore";
        list ( $resp, $header ) = $this->send("GET", $project, null, $resource, $params, $headers);

        $requestId = isset ( $header ['x-log-requestid'] ) ? $header ['x-log-requestid'] : '';
        $resp      = $this->parseToJson($resp, $requestId);

        return new GetLogsResponse ($resp, $header);
    }
1140785
public function send(Request $request)
    {
        $interface = $request->getInterface();
        $service = ConfigFactory::getClient()->getService($interface);
        $url = $service->getUrl();

        $requestRaw = Formatter::serialize($request);
        $responseRaw = $this->protocol->sendData($url, $requestRaw);
        $response = @Formatter::unserialize($responseRaw);
        if (!($response instanceof Response)) {
            LoggerProxy::getInstance()->error("illegal response", array($responseRaw));
            throw new InitiallyRpcException("illegal response");
        } elseif ($response->isHasException()) {
            $exception = $response->getException();
            if (is_object($exception) && $exception instanceof Exception) {
                throw $exception;
            } else if (is_string($exception)) {
                if (class_exists($exception)) {
                    throw new $exception($response->getExceptionMessage());
                } else {
                    throw new InitiallyRpcException($response->getExceptionMessage());
                }
            }
        }

        return $response->getResult();
    }
973118
public function logs(Request $request, DataTables $dataTables)
    {
        if ($request->input('l')) {
            LaravelLogViewer::setFile(base64_decode($request->input('l')));
        }

        if ($request->input('dl')) {
            return response()->download(LaravelLogViewer::pathToLogFile(base64_decode($request->input('dl'))));
        } elseif ($request->has('del')) {
            File::delete(LaravelLogViewer::pathToLogFile(base64_decode($request->input('del'))));

            return redirect()->to($request->url());
        }

        $logs = LaravelLogViewer::all();

        if ($request->wantsJson()) {
            return $dataTables->collection(collect($logs))
                              ->editColumn('stack', '{!! nl2br($stack) !!}')
                              ->editColumn('level', function ($log) {
                                  $content = html()->tag('span', '', [
                                      'class' => "glyphicon glyphicon-{$log['level_img']}-sign",
                                  ]);

                                  $content .= '&nbsp;' . $log['level'];

                                  return html()->tag('span', $content, ['class' => "text-{$log['level_class']}"]);
                              })
                              ->addColumn('content', function ($log) {
                                  $html = '';
                                  if ($log['stack']) {
                                      $html = '<a class="pull-right expand btn btn-default btn-xs"><span class="glyphicon glyphicon-search"></span></a>';
                                  }

                                  $html .= $log['text'];

                                  if (isset($log['in_file'])) {
                                      $html .= '<br>' . $log['in_file'];
                                  }

                                  return $html;
                              })
                              ->rawColumns(['content'])
                              ->toJson();
        }

        return view('administrator.utilities.log', [
            'logs'         => $logs,
            'files'        => LaravelLogViewer::getFiles(true),
            'current_file' => LaravelLogViewer::getFileName(),
        ]);
    }
1231943
public function handleRequest($request)
    {
        // recursion for batch
        if ($request->isBatch()) {
            $batch = array();
            foreach ($request->requests as $req) {
                $batch[] = $this->handleRequest($req);
            }
            $responses = implode(',',array_filter($batch, function($a){return $a !== null;}));
            if ($responses != null) {
                return "[{$responses}]";
            } else {
                return null;
            }
        }

        // check validity of request
        if ($request->checkValid()) {
            // check for method existence
            if (!$this->methodExists($request->method)) {
                $request->error_code = ERROR_METHOD_NOT_FOUND;
                $request->error_message = "Method not found.";
                return $request->toResponseJSON();
            }

            // try to call method with params
            try {
                $response = $this->invokeMethod($request->method, $request->params);
                if (!$request->isNotify()) {
                    $request->result = $response;
                } else {
                    return null;
                }
            // handle exceptions
            } catch (\Exception $e) {
                $request->error_code = ERROR_EXCEPTION;
                $request->error_message = $e->getMessage();
            }
        }

        // return whatever we got
        return $request->toResponseJSON();
    }
846472
public function handle($request)
    {
        $this->loadAuthManager();
        
        try {
            $response = $this->sendRequestThroughRouter($request);
            $response = $response->getContent();
            
            $json = json_decode($response, true);
            if (json_last_error() == JSON_ERROR_NONE) {
                $response = $json;
            }
        } catch (Exception $e) {
            if ($e instanceof NotFoundHttpException) {
                $response = $e;
            } else {
                throw $e;
            }
        }
        
        $this->app['events']->fire('wskernel.handled', [$request, $response]);
        
        return $response;
    }
959828
function logexception(\Exception $exception) {
		try {
			$message = $exception->getMessage();
			$trace = $exception->getTraceAsString();
			$trace = $this->becloud($trace);
			$trace = str_replace("\n", "\n\t", trim($trace, " \n\r\t"));
			$this->log("$message\n\n\t$trace\n");
		}
		catch (\Exception $e) {
			$this->failedLogging($e, $exception->getMessage());
		}
	}
209740
public function filter($request)
	{
		foreach($this->_filters as $filter)
		{
			if(!$request = $filter->filter($request))
			{
				throw new Exception("Filter returned a null request");
			}
		}

		return $request;
	}
416964
protected function _logException(Exception $exception) {
		if ($this->is404($exception)) {
			$level = LOG_ERR;
			Log::write($level, $this->_getMessage($exception), ['404']);
			return false;
		}
		return parent::_logException($exception);
	}
588811
public function transferlog(SS_HTTPRequest $request) {
		$params = $request->params();
		$transfer = DNDataTransfer::get()->byId($params['Identifier']);

		if(!$transfer || !$transfer->ID) throw new SS_HTTPResponse_Exception('Transfer not found', 404);
		if(!$transfer->canView()) return Security::permissionFailure();

		$environment = $transfer->Environment();
		$project = $environment->Project();

		if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy");

		$log = $transfer->log();
		if($log->exists()) {
			$content = $log->content();
		} else {
			$content = 'Waiting for action to start';
		}

		$sendJSON = (strpos($request->getHeader('Accept'), 'application/json') !== false)
			|| $request->getExtension() == 'json';


		$content = preg_replace('/(?:(?:\r\n|\r|\n)\s*){2}/s', "\n", $content);
		if($sendJSON) {
			$this->response->addHeader("Content-type", "application/json");
			return json_encode(array(
				'status' => $transfer->ResqueStatus(),
				'content' => $content,
			));

		} else {
			$this->response->addHeader("Content-type", "text/plain");
			return $content;
		}

	}
828392
public function showAction(Request $request, $exception, DebugLoggerInterface $logger = null)
    {
        $currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
        $code = $this->getStatusCode($exception);
        $templateData = $this->getTemplateData($currentContent, $code, $exception, $logger);

        $view = $this->createView($exception, $code, $templateData, $request, $this->showException);
        $response = $this->viewHandler->handle($view);

        return $response;
    }
329553
public function dispatch(Request $request)
    {
        $this->logger->debug('Dispatching request');
        try {
            /**
             * @var \Shade\Router\RouterInterface $router
             */
            $router = $this->serviceContainer->getService(ServiceContainer::SERVICE_ROUTER);
            $route = $router->route($request);
            if (!isset($this->primaryRequest)) {
                $this->primaryRequest = $request;
                $logMessage = 'Route found for primary request';
            } else {
                $logMessage = 'Route found for secondary request';
            }
            if (!isset($this->primaryRoute)) {
                $this->primaryRoute = $route;
            }
        } catch (Exception $e) {
            $this->logger->debug('Route not found');
            $response = new Response();
            $response->setCode(404);

            return $response;
        }

        $this->validateRoute($route);
        $this->logger->debug(
            $logMessage,
            [
                'controller' => $route->controller(),
                'action' => $route->action(),
                'args' => $route->args(),
            ]
        );
        $controllerClass = $route->controller();
        $actionName = $route->action();
        $actionArguments = $this->getMethodArguments($controllerClass, $actionName);

        if (method_exists($controllerClass, '__construct')) {
            $constructorArguments = $this->getMethodArguments($controllerClass, '__construct');
        }

        if (empty($constructorArguments)) {
            $controller = new $controllerClass();
        } else {
            $controllerReflection = new \ReflectionClass($controllerClass);
            $controller = $controllerReflection->newInstanceArgs($constructorArguments);
        }

        if (!($controller instanceof Controller)) {
            throw new Exception(
                "'{$controllerClass}' must inherit '\\Shade\\Controller'."
            );
        }

        /**
         * @var \Shade\Controller $controller
         */
        $controller->setControllerDispatcher($this);
        $controller->setView($this->serviceContainer->getService(ServiceContainer::SERVICE_VIEW));
        $controller->setCurrentRequest($request);
        $controller->setCurrentRoute($route);
        $controller->setPrimaryRequest($request);
        $controller->setPrimaryRoute($route);

        /**
         * @var Response $response
         */
        $response = call_user_func_array([$controller, $actionName], $actionArguments);
        if (!$response instanceof Response) {
            throw new Exception(
                "Executed controller hasn't returned instance of \\Shade\\Response. "
                .ucfirst(gettype($response)).' has been returned.'
            );
        }

        if (!$response->getCode()) {
            $response->setCode(200);
        }

        return $response;
    }
299442
protected function inExceptArray($request)
    {
        foreach (config('admin.operation_log.except') as $except) {
            if ('/' !== $except) {
                $except = trim($except, '/');
            }

            $methods = [];

            if (Str::contains($except, ':')) {
                list($methods, $except) = explode(':', $except);
                $methods = explode(',', $methods);
            }

            $methods = array_map('strtoupper', $methods);

            if ($request->is($except) &&
                (empty($methods) || in_array($request->method(), $methods, true))) {
                return true;
            }
        }

        return false;
    }
628221
public LogStreamResponse getLogs(Log.LogRequestBuilder logRequest) {
        return connection.execute(new Log(logRequest), apiKey);
    }
1313223
protected function doRequestInProcess($request)
    {
        $process = new PhpProcess($this->getScript($request), null, null);
        $process->run();

        if (!$process->isSuccessful() || !preg_match('/^O\:\d+\:/', $process->getOutput())) {
            throw new \RuntimeException(sprintf('OUTPUT: %s ERROR OUTPUT: %s', $process->getOutput(), $process->getErrorOutput()));
        }

        return unserialize($process->getOutput());
    }
1289334
protected function recordFromRequest($request)
    {
        if (!SecurityToken::inst()->checkRequest($request)) {
            return $this->respondWithMessage(false);
        }

        $id = $request->param('ID');

        if (!$id || !is_numeric($id)) {
            return $this->respondWithMessage(false, "Cannot find record with ID: '$id'", 400);
        }

        $class = $this->owner->config()->tree_class ?: 'SiteTree';
        $record = OriginalDataObject::get_by_id($class, $id);

        if (!$record || !$record->ID) {
            return $this->respondWithMessage(false, "Bad record ID: '$id''", 404);
        }

        return $record;
    }
232772
public function execute(Request $request)
    {
        if (!$this->requireProvider("Executing cache request")) return null;

        $cacheKey = $request->getCacheKey();

        if (empty($cacheKey)) {
            if (!empty($this->log)) $this->log->error("Invalid or missing cache key.");
            return null;
        }

        $cacheRefresh = $request->getForceRefresh();

        if (!$cacheRefresh) {
            $cacheData = $this->cacheProvider->get($cacheKey);

            if (!empty($cacheData)) {
                if (!empty($this->log)) $this->log->debug("Cache hit on key " . $cacheKey);

                return $cacheData;
            }
        }

        if (!empty($this->log)) $this->log->debug("CACHE", "Cache miss on key " . $cacheKey);

        $value = $request->executeCallback();

        if (!empty($value)) {
            $this->cacheProvider->set($cacheKey, $value, $request->getCacheTTL());
        }

        return $value;
    }
666727
public function laraException(Request $request)
    {



        $storage = Storage::disk('local');
        $fileName = base64_decode(urldecode($request->get('errors')));
        if(!$storage->exists($fileName)){
            $info = null;
        }else{
            $info = $storage->get($fileName);
        }

        $view = self::VIEW_DEFAULT;

       // $info = $request->cookie('lara_exception_code');
        $errors =[];
        if(is_null($info)){
            $errors  = [
                'details' => '',
                'message' => 'LaraException',
                'debugCode' => '0',
                'errors' => [],
                'routeBack' => ''
            ];
        }else{
            //$urlEncode = \Crypt::decrypt($info);
            //\Cookie::forget('lara_exception_code');
            ///$urlEncode = urldecode($info);
            $storage->delete($fileName);

            $data = json_decode(base64_decode($info),true);
            $errors = $data['errors'];
            $view = $data['view'];
        }
        return view($view,$errors);
    }