d

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.

15 St Margarets, NY 10033
(+381) 11 123 4567
ouroffice@aware.com

 

KMF

Nova Log Viewer Package | Laravel News

Laravel Nova author David Hemphill released the Nova Log Viewer source code—a tool for viewing your application logs via the Nova UI:

The UI allows you to select which log file to view and even supports polling. Further, you can use the source code to see how these tools integrate with Nova and use it as a starting point to build your own.

While looking through the source code, I found a couple of gems (to me), such as defining an invokable controller and using the same controller to define another method for the API call to get logs.

The fetch API controller method shows off a neat instance method I’ve not used before called contentAfterLine:

1/**

2 * Fetch the latest content for a log.

3 *

4 * @param LaravelNovaHttpRequestsNovaRequest $request

5 * @return IlluminateHttpJsonResponse

6 */

7public function fetch(NovaRequest $request)

8{

9 $request->validate(['lastLine' => ['numeric']]);

10 $logFile = new File($request->log);

11 $lines = $logFile->contentAfterLine($request->lastLine);

12 $lastLine = $request->lastLine + substr_count($lines, PHP_EOL);

13 

14 return response()->json([

15 'lastLine' => $lastLine,

16 'content' => $lines,

17 'numberOfLines' => $logFile->numberOfLines(),

18 ]);

19}

Learn More

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Laravel Nova v4 was released in April 2002—here are some resources to get started with the latest version:


Credit: Source link

Previous Next
Close
Test Caption
Test Description goes like this