add log viewer

This commit is contained in:
Saeed Vaziry
2025-06-19 15:32:52 +02:00
parent 48c4d53d31
commit 2081bdd46e
13 changed files with 550 additions and 14 deletions

View File

@ -19,6 +19,7 @@
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.8",
"mobiledetect/mobiledetectlib": "^4.8",
"opcodesio/log-viewer": "^3.17",
"phpseclib/phpseclib": "~3.0",
"spatie/laravel-route-attributes": "^1.24",
"tightenco/ziggy": "^2.5"

143
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "960ed00630c6fb18034953f4279762a7",
"content-hash": "f9540de1e2dd90b20d9fe05386e75252",
"packages": [
{
"name": "aws/aws-crt-php",
@ -3231,6 +3231,147 @@
],
"time": "2025-05-08T08:14:37+00:00"
},
{
"name": "opcodesio/log-viewer",
"version": "v3.17.1",
"source": {
"type": "git",
"url": "https://github.com/opcodesio/log-viewer.git",
"reference": "871b7ac2adf8e623b3145e438fb2a2fdc0f8476c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opcodesio/log-viewer/zipball/871b7ac2adf8e623b3145e438fb2a2fdc0f8476c",
"reference": "871b7ac2adf8e623b3145e438fb2a2fdc0f8476c",
"shasum": ""
},
"require": {
"illuminate/contracts": "^8.0|^9.0|^10.0|^11.0|^12.0",
"opcodesio/mail-parser": "^0.1.6",
"php": "^8.0"
},
"conflict": {
"arcanedev/log-viewer": "^8.0"
},
"require-dev": {
"guzzlehttp/guzzle": "^7.2",
"itsgoingd/clockwork": "^5.1",
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.0|^8.0",
"orchestra/testbench": "^7.6|^8.0|^9.0|^10.0",
"pestphp/pest": "^2.0|^3.7",
"pestphp/pest-plugin-laravel": "^2.0|^3.1",
"spatie/test-time": "^1.3"
},
"suggest": {
"guzzlehttp/guzzle": "Required for multi-host support. ^7.2"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"LogViewer": "Opcodes\\LogViewer\\Facades\\LogViewer"
},
"providers": [
"Opcodes\\LogViewer\\LogViewerServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Opcodes\\LogViewer\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Arunas Skirius",
"email": "arukomp@gmail.com",
"role": "Developer"
}
],
"description": "Fast and easy-to-use log viewer for your Laravel application",
"homepage": "https://github.com/opcodesio/log-viewer",
"keywords": [
"arukompas",
"better-log-viewer",
"laravel",
"log viewer",
"logs",
"opcodesio"
],
"support": {
"issues": "https://github.com/opcodesio/log-viewer/issues",
"source": "https://github.com/opcodesio/log-viewer/tree/v3.17.1"
},
"funding": [
{
"url": "https://www.buymeacoffee.com/arunas",
"type": "custom"
},
{
"url": "https://github.com/arukompas",
"type": "github"
}
],
"time": "2025-05-19T09:20:51+00:00"
},
{
"name": "opcodesio/mail-parser",
"version": "v0.1.6",
"source": {
"type": "git",
"url": "https://github.com/opcodesio/mail-parser.git",
"reference": "639ef31cbd146a63416283e75afce152e13233ea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opcodesio/mail-parser/zipball/639ef31cbd146a63416283e75afce152e13233ea",
"reference": "639ef31cbd146a63416283e75afce152e13233ea",
"shasum": ""
},
"require": {
"php": "^8.0"
},
"require-dev": {
"pestphp/pest": "^2.16",
"symfony/var-dumper": "^6.3"
},
"type": "library",
"autoload": {
"psr-4": {
"Opcodes\\MailParser\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Arunas Skirius",
"email": "arukomp@gmail.com",
"role": "Developer"
}
],
"description": "Parse emails without the mailparse extension",
"keywords": [
"arukompas",
"email",
"email parser",
"mail",
"opcodesio",
"php"
],
"support": {
"issues": "https://github.com/opcodesio/mail-parser/issues",
"source": "https://github.com/opcodesio/mail-parser/tree/v0.1.6"
},
"time": "2023-11-19T08:47:43+00:00"
},
{
"name": "paragonie/constant_time_encoding",
"version": "v3.0.0",

308
config/log-viewer.php Normal file
View File

@ -0,0 +1,308 @@
<?php
use Opcodes\LogViewer\Enums\FolderSortingMethod;
use Opcodes\LogViewer\Enums\SortingOrder;
use Opcodes\LogViewer\Enums\Theme;
return [
/*
|--------------------------------------------------------------------------
| Log Viewer
|--------------------------------------------------------------------------
| Log Viewer can be disabled, so it's no longer accessible via browser.
|
*/
'enabled' => env('LOG_VIEWER_ENABLED', true),
'api_only' => env('LOG_VIEWER_API_ONLY', false),
'require_auth_in_production' => true,
/*
|--------------------------------------------------------------------------
| Log Viewer Domain
|--------------------------------------------------------------------------
| You may change the domain where Log Viewer should be active.
| If the domain is empty, all domains will be valid.
|
*/
'route_domain' => null,
/*
|--------------------------------------------------------------------------
| Log Viewer Route
|--------------------------------------------------------------------------
| Log Viewer will be available under this URL.
|
*/
'route_path' => 'logs',
/*
|--------------------------------------------------------------------------
| Back to system URL
|--------------------------------------------------------------------------
| When set, displays a link to easily get back to this URL.
| Set to `null` to hide this link.
|
| Optional label to display for the above URL.
|
*/
'back_to_system_url' => config('app.url', null),
'back_to_system_label' => null, // Displayed by default: "Back to {{ app.name }}"
/*
|--------------------------------------------------------------------------
| Log Viewer time zone.
|--------------------------------------------------------------------------
| The time zone in which to display the times in the UI. Defaults to
| the application's timezone defined in config/app.php.
|
*/
'timezone' => null,
/*
|--------------------------------------------------------------------------
| Log Viewer datetime format.
|--------------------------------------------------------------------------
| The format used to display timestamps in the UI.
|
*/
'datetime_format' => 'Y-m-d H:i:s',
/*
|--------------------------------------------------------------------------
| Log Viewer route middleware.
|--------------------------------------------------------------------------
| Optional middleware to use when loading the initial Log Viewer page.
|
*/
'middleware' => [
'web',
\Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer::class,
'auth',
\App\Http\Middleware\MustBeAdminMiddleware::class,
],
/*
|--------------------------------------------------------------------------
| Log Viewer API middleware.
|--------------------------------------------------------------------------
| Optional middleware to use on every API request. The same API is also
| used from within the Log Viewer user interface.
|
*/
'api_middleware' => [
\Opcodes\LogViewer\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
\Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer::class,
],
'api_stateful_domains' => env('LOG_VIEWER_API_STATEFUL_DOMAINS') ? explode(',', env('LOG_VIEWER_API_STATEFUL_DOMAINS')) : null,
/*
|--------------------------------------------------------------------------
| Log Viewer Remote hosts.
|--------------------------------------------------------------------------
| Log Viewer supports viewing Laravel logs from remote hosts. They must
| be running Log Viewer as well. Below you can define the hosts you
| would like to show in this Log Viewer instance.
|
*/
'hosts' => [
'local' => [
'name' => ucfirst(env('APP_ENV', 'local')),
],
// 'staging' => [
// 'name' => 'Staging',
// 'host' => 'https://staging.example.com/log-viewer',
// 'auth' => [ // Example of HTTP Basic auth
// 'username' => 'username',
// 'password' => 'password',
// ],
// 'verify_server_certificate' => true,
// ],
//
// 'production' => [
// 'name' => 'Production',
// 'host' => 'https://example.com/log-viewer',
// 'auth' => [ // Example of Bearer token auth
// 'token' => env('LOG_VIEWER_PRODUCTION_TOKEN'),
// ],
// 'headers' => [
// 'X-Foo' => 'Bar',
// ],
// 'verify_server_certificate' => true,
// ],
],
/*
|--------------------------------------------------------------------------
| Include file patterns
|--------------------------------------------------------------------------
|
*/
'include_files' => [
'*.log',
'**/*.log',
// You can include paths to other log types as well, such as apache, nginx, and more.
// This key => value pair can be used to rename and group multiple paths into one folder in the UI.
'/var/log/httpd/*' => 'Apache',
'/var/log/nginx/*' => 'Nginx',
// MacOS Apple Silicon logs
'/opt/homebrew/var/log/nginx/*',
'/opt/homebrew/var/log/httpd/*',
'/opt/homebrew/var/log/php-fpm.log',
'/opt/homebrew/var/log/postgres*log',
'/opt/homebrew/var/log/redis*log',
'/opt/homebrew/var/log/supervisor*log',
// '/absolute/paths/supported',
],
/*
|--------------------------------------------------------------------------
| Exclude file patterns.
|--------------------------------------------------------------------------
| This will take precedence over included files.
|
*/
'exclude_files' => [
// 'my_secret.log'
],
/*
|--------------------------------------------------------------------------
| Hide unknown files.
|--------------------------------------------------------------------------
| The include/exclude options above might catch files which are not
| logs supported by Log Viewer. In that case, you can hide them
| from the UI and API calls by setting this to true.
|
*/
'hide_unknown_files' => true,
/*
|--------------------------------------------------------------------------
| Shorter stack trace filters.
|--------------------------------------------------------------------------
| Lines containing any of these strings will be excluded from the full log.
| This setting is only active when the function is enabled via the user interface.
|
*/
'shorter_stack_trace_excludes' => [
'/vendor/symfony/',
'/vendor/laravel/framework/',
'/vendor/barryvdh/laravel-debugbar/',
],
/*
|--------------------------------------------------------------------------
| Cache driver
|--------------------------------------------------------------------------
| Cache driver to use for storing the log indices. Indices are used to speed up
| log navigation. Defaults to your application's default cache driver.
|
*/
'cache_driver' => env('LOG_VIEWER_CACHE_DRIVER', null),
/*
|--------------------------------------------------------------------------
| Cache key prefix
|--------------------------------------------------------------------------
| Log Viewer prefixes all the cache keys created with this value. If for
| some reason you would like to change this prefix, you can do so here.
| The format of Log Viewer cache keys is:
| {prefix}:{version}:{rest-of-the-key}
|
*/
'cache_key_prefix' => 'lv',
/*
|--------------------------------------------------------------------------
| Chunk size when scanning log files lazily
|--------------------------------------------------------------------------
| The size in MB of files to scan before updating the progress bar when searching across all files.
|
*/
'lazy_scan_chunk_size_in_mb' => 50,
'strip_extracted_context' => true,
/*
|--------------------------------------------------------------------------
| Per page options
|--------------------------------------------------------------------------
| Define the available options for number of results per page
|
*/
'per_page_options' => [10, 25, 50, 100, 250, 500],
/*
|--------------------------------------------------------------------------
| Default settings for Log Viewer
|--------------------------------------------------------------------------
| These settings determine the default behaviour of Log Viewer. Many of
| these can be persisted for the user in their browser's localStorage,
| if the `use_local_storage` option is set to true.
|
*/
'defaults' => [
// Whether to use browser's localStorage to store user preferences.
// If true, user preferences saved in the browser will take precedence over the defaults below.
'use_local_storage' => true,
// Method to sort the folders. Other options: `Alphabetical`, `ModifiedTime`
'folder_sorting_method' => FolderSortingMethod::ModifiedTime,
// Order to sort the folders. Other options: `Ascending`, `Descending`
'folder_sorting_order' => SortingOrder::Descending,
// Order to sort the logs. Other options: `Ascending`, `Descending`
'log_sorting_order' => SortingOrder::Descending,
// Number of results per page. Must be one of the above `per_page_options` values
'per_page' => 25,
// Color scheme for the Log Viewer. Other options: `System`, `Light`, `Dark`
'theme' => Theme::System,
// Whether to enable `Shorter Stack Traces` option by default
'shorter_stack_traces' => false,
],
/*
|--------------------------------------------------------------------------
| Root folder prefix
|--------------------------------------------------------------------------
| The prefix for log files inside Laravel's `storage/logs` folder.
| Log Viewer does not show the full path to these files in the UI,
| but only the filename prefixed with this value.
|
*/
'root_folder_prefix' => 'root',
];

1
public/vendor/log-viewer/app.css vendored Normal file

File diff suppressed because one or more lines are too long

2
public/vendor/log-viewer/app.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,33 @@
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
/*!
* pinia v2.2.2
* (c) 2024 Eduardo San Martin Morote
* @license MIT
*/
/*! #__NO_SIDE_EFFECTS__ */
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/**
* @vue/shared v3.4.38
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 B

View File

@ -0,0 +1,7 @@
{
"/app.js": "/app.js?id=74d3e481ad3e8fa14f1daaa0aa46e109",
"/app.css": "/app.css?id=5593a0331dd40729ff41e32a6035d872",
"/img/log-viewer-128.png": "/img/log-viewer-128.png?id=d576c6d2e16074d3f064e60fe4f35166",
"/img/log-viewer-32.png": "/img/log-viewer-32.png?id=f8ec67d10f996aa8baf00df3b61eea6d",
"/img/log-viewer-64.png": "/img/log-viewer-64.png?id=8902d596fc883ca9eb8105bb683568c6"
}

View File

@ -13,7 +13,7 @@ import {
SidebarMenuSubItem,
} from '@/components/ui/sidebar';
import { type NavItem } from '@/types';
import { Link, router } from '@inertiajs/react';
import { Link } from '@inertiajs/react';
import { BookOpen, ChevronRightIcon, CogIcon, Folder, MousePointerClickIcon, ServerIcon, ZapIcon } from 'lucide-react';
import AppLogo from './app-logo';
import { Icon } from '@/components/icon';
@ -84,10 +84,17 @@ export function AppSidebar({ secondNavItems, secondNavTitle }: { secondNavItems?
isActive={item.onlyActivePath ? window.location.href === item.href : window.location.href.startsWith(item.href)}
tooltip={{ children: item.title, hidden: false }}
>
{item.external ? (
<a href={item.href} target="_blank">
{item.icon && <item.icon />}
<span>{item.title}</span>
</a>
) : (
<Link href={item.href} prefetch>
{item.icon && <item.icon />}
<span>{item.title}</span>
</Link>
)}
</SidebarMenuButton>
</SidebarMenuItem>
))}
@ -152,10 +159,17 @@ export function AppSidebar({ secondNavItems, secondNavTitle }: { secondNavItems?
: window.location.href.startsWith(childItem.href)
}
>
{childItem.external ? (
<a href={childItem.href} target="_blank">
{childItem.icon && <childItem.icon />}
<span>{childItem.title}</span>
</a>
) : (
<Link href={childItem.href} prefetch>
{childItem.icon && <childItem.icon />}
<span>{childItem.title}</span>
</Link>
)}
</SidebarMenuButton>
</SidebarMenuSubItem>
))}
@ -168,9 +182,18 @@ export function AppSidebar({ secondNavItems, secondNavTitle }: { secondNavItems?
return (
<SidebarMenuItem key={`${item.title}-${item.href}`} hidden={item.hidden}>
<SidebarMenuButton onClick={() => router.visit(item.href)} isActive={isActive} disabled={item.isDisabled || false}>
<SidebarMenuButton isActive={isActive} disabled={item.isDisabled || false} asChild>
{item.external ? (
<a href={item.href} target="_blank">
{item.icon && <item.icon />}
<span>{item.title}</span>
</a>
) : (
<Link href={item.href} disabled={item.isDisabled || false}>
{item.icon && <item.icon />}
<span>{item.title}</span>
</Link>
)}
</SidebarMenuButton>
</SidebarMenuItem>
);

View File

@ -1,5 +1,18 @@
import { type BreadcrumbItem, type NavItem } from '@/types';
import { BellIcon, CloudIcon, CodeIcon, CommandIcon, DatabaseIcon, KeyIcon, ListIcon, PlugIcon, TagIcon, UserIcon, UsersIcon } from 'lucide-react';
import {
BellIcon,
CloudIcon,
CodeIcon,
CommandIcon,
DatabaseIcon,
KeyIcon,
ListIcon,
LogsIcon,
PlugIcon,
TagIcon,
UserIcon,
UsersIcon,
} from 'lucide-react';
import { ReactNode } from 'react';
import Layout from '@/layouts/app/layout';
import VitoIcon from '@/icons/vito';
@ -65,6 +78,12 @@ const sidebarNavItems: NavItem[] = [
href: route('vito-settings'),
icon: VitoIcon,
},
{
title: 'Vito Logs',
href: route('log-viewer.index'),
icon: LogsIcon,
external: true,
},
];
export default function SettingsLayout({ children, breadcrumbs }: { children: ReactNode; breadcrumbs?: BreadcrumbItem[] }) {

View File

@ -31,6 +31,7 @@ export interface NavItem {
isDisabled?: boolean;
children?: NavItem[];
hidden?: boolean;
external?: boolean;
}
export interface Configs {