Skip to content

Conversation

shigristudy
Copy link

📝 Description
This PR enhances the log viewer experience for Laravel developers by adding a beautiful Stack Trace tab that automatically appears when Laravel exception logs contain stack trace information.

🚀 What's Changed
Added Stack Trace Tab: A new tab appears automatically for Laravel logs containing [stacktrace] sections
Exception Header Display: Shows exception type, message, and location with proper styling
Stack Trace Frames: Displays numbered frames with file paths, line numbers, and method calls
Performance Optimized: Stack traces are only parsed when the tab is clicked (lazy loading)
Maintains Existing Behavior: Raw tab remains the default, all existing functionality preserved

🎨 Visual Improvements
The new Stack Trace tab provides:

Exception Header: Red-highlighted exception type with clear error message
File Paths: Blue-colored file paths with orange line numbers
Frame Numbers: Gray-styled frame indicators (#0, #1, etc.)
Responsive Design: Works seamlessly on both desktop and mobile
Dark Mode Support: Proper styling for both light and dark themes

💻 Technical Details
Files Modified:

BaseLogTable.vue - Added stack trace detection and parsing logic
Key Functions Added:

hasLaravelStackTrace(log) - Lightweight detection of stack traces
getStackTraceData(log) - Parses exception headers and stack frames
Enhanced getTabsForLog(log) - Includes Stack Trace tab when applicable
Parser Features:

Detects Laravel exception format with [stacktrace] sections
Parses exception headers: [object] (ExceptionType(code: 0): Message at /path/file.php:123)
Extracts stack frames: #0 /path/file.php(123): Class::method()
Handles edge cases for malformed or incomplete stack traces

📱 Usage Example

When viewing a Laravel error log like this:
[2024-01-15 10:30:45] local.ERROR: Call to undefined method  
{"exception":"[object] (Error(code: 0): Call to undefined method App\\Models\\User::invalidMethod() at /app/Http/Controllers/UserController.php:25)
[stacktrace]
#0 /app/Http/Controllers/UserController.php(25): App\\Models\\User::invalidMethod()
#1 /vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\UserController->show()
#2 /vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): call_user_func_array()"}

The Stack Trace tab will automatically appear and display:

Exception Type: Error
Message: Call to undefined method App\Models\User::invalidMethod()
Location: in /app/Http/Controllers/UserController.php:25
Stack Frames: Properly formatted with file paths and line numbers

🎯 Benefits
Better Debugging Experience: Developers can quickly identify error locations
Improved Readability: Clean, formatted display vs raw text
Time Saving: No need to manually parse stack traces
Laravel-Specific: Tailored for Laravel's exception format
Non-Breaking: Existing functionality remains unchanged

image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant