Search by

diarsa / logview

diarsa

Fast, memory-safe, zero-build log viewer for Laravel. Reads multi-GB log files backwards with cursor pagination.

Package info

github.com/diarsa/logview

pkg:composer/diarsa/logview

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-12-03 07:10 UTC

This package is not auto-updated.

Last update: 2026-12-04 06:44:01 UTC


README

A fast, lightweight log viewer for Laravel. No build step is needed: the UI is a single Blade file that uses Tailwind CSS and Alpine.js. Both libraries are bundled inside the package (resources/dist), so it works offline and on private networks without any CDN. Large log files (even several GB) are read backwards in small chunks (fseek), so the whole file is never loaded into memory.

Features

  • Newest entries first, with cursor-based pagination (by byte offset)
  • Supports single and daily logs, plus sub-folders inside storage/logs
  • Splits each entry into timestamp, environment, level, message, JSON context, exception and stack trace (vendor frames can be collapsed)
  • Filter by level (with a count for each level), search on the server (limited by bytes and time, so it never times out), and filter by date range
  • Sort the file list by last modified, name, size or number of entries
  • Dark and light mode, word wrap or horizontal scroll, copy raw entry, JSON pretty-print, live tail
  • Download (streamed), clear (truncate) and delete log files
  • Protected by the viewLogview Gate, safe against path traversal (realpath()), and hides sensitive data automatically

Structure

logview/
├── composer.json
├── config/logview.php
├── routes/web.php
├── resources/views/index.blade.php
├── resources/dist/                    # bundled Tailwind CSS + Alpine.js (no CDN needed)
├── src/
│   ├── LogviewServiceProvider.php
│   ├── Http/Controllers/LogviewController.php
│   ├── Http/Middleware/Authorize.php
│   ├── Services/LogStreamReader.php     # reads the file backwards and builds multi-line entries
│   ├── Services/LogParser.php           # parses header, context, exception and stack frames
│   ├── Services/LogFileRepository.php   # lists files and resolves paths safely
│   ├── Services/LogStatsService.php     # counts levels step by step, with caching
│   └── Support/{LogFile,Masker}.php
└── tests/

Installation

composer require diarsa/logview
php artisan vendor:publish --tag=logview-config   # optional

Open /logview in your browser. By default, only the local environment can access it. To allow access in production, define the Gate (the same way as Laravel Horizon):

// app/Providers/AppServiceProvider.php -> boot()
Gate::define('viewLogview', fn ($user) => in_array($user->email, ['admin@example.com']));

or

Gate::define('viewLogview', function (?User $user = null) {
    return $user && $user->hasRole('superadmin');
});

JSON Endpoints

Method URI Description
GET /logview/api/files List log files
GET /logview/api/entries?file=&cursor=&per_page=&levels[]=&q=&from=&to= Log entries, newest first
GET /logview/api/stats?file= Number of entries per level (counted step by step)
GET /logview/download?file= Download the file (streamed)
POST /logview/api/files/clear Clear (truncate) the file
DELETE /logview/api/files Delete the file

The entries response includes meta.next_cursor for loading the next page. If meta.partial is true, the search reached its scan limit before finding enough results, and the UI shows a "Continue searching" button.

License

MIT