/** * Log viewer. * * @param \Illuminate\Http\Request $request * @param \Yajra\Datatables\Datatables $datatables * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View|\Symfony\Component\HttpFoundation\BinaryFileResponse * @throws \Exception */ 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 = $this->html->tag('span', '', ['class' => "glyphicon glyphicon-{$log['level_img']}-sign"]); $content .= ' ' . $log['level']; return $this->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; })->make(true); } return view('administrator.utilities.log', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]); }