Skip to content

Commit

Permalink
Merge pull request #24 from saade/feat/v3-support
Browse files Browse the repository at this point in the history
v3 support
  • Loading branch information
saade authored Aug 31, 2023
2 parents c49c381 + 649e8f5 commit fa544ca
Show file tree
Hide file tree
Showing 38 changed files with 6,066 additions and 685 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

Expand Down
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
.DS_Store
.idea
.php_cs
.php_cs.cache
.phpunit.result.cache
.vscode
build
composer.lock
coverage
docs
node_modules
phpunit.xml
phpstan.neon
testbench.yaml
vendor
node_modules
.php-cs-fixer.cache
40 changes: 0 additions & 40 deletions .php_cs.dist.php

This file was deleted.

160 changes: 60 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
# Access laravel log through Filament admin panel

![Log Viewer](./art/preview.jpeg)
# Filament Laravel Log

[![Latest Version on Packagist](https://img.shields.io/packagist/v/saade/filament-laravel-log.svg?style=flat-square)](https://packagist.org/packages/saade/filament-laravel-log)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/saade/filament-laravel-log/run-tests?label=tests)](https://github.com/saade/filament-laravel-log/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/saade/filament-laravel-log/Check%20&%20fix%20styling?label=code%20style)](https://github.com/saade/filament-laravel-log/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/saade/filament-laravel-log.svg?style=flat-square)](https://packagist.org/packages/saade/filament-laravel-log)

<p align="center">
<img src="https://raw.githubusercontent.com/saade/filament-laravel-log/3.x/art/cover.png" alt="Banner" style="width: 100%; max-width: 800px; border-radius: 10px" />
</p>

# Features

- Syntax highlighting
- Light/ Dark mode
- Quickly jump between start and end of the file
- Refresh log contents
- Clear log contents
- Search multiple files in multiple directories <sup>New in v1.1.0</sup>
- Ignore file patterns <sup>New in v1.1.0</sup>

<br>

## Support Filament

<a href="https://github.com/sponsors/danharrin">
<img width="320" alt="filament-logo" src="https://filamentadmin.com/images/sponsor-banner.jpg">
</a>
- Search multiple files in multiple directories
- Ignored file patterns

<br>

Expand All @@ -31,72 +24,70 @@
You can install the package via composer:

```bash
composer require saade/filament-laravel-log
composer require saade/filament-laravel-log:^3.0
```

## Usage

Just install the package and you're ready to go!

## Configuration
Add the `Saade\FilamentLaravelLog\FilamentLaravelLogPlugin` to your panel config.

You can publish the config file with:
```php
use Saade\FilamentLaravelLog\FilamentLaravelLogPlugin;

```bash
php artisan vendor:publish --tag="log-config"
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(
FilamentLaravelLogPlugin::make()
);
}
}
```

This is the contents of the published config file:
## Configuration

```php
<?php
### Customizing the navigation item

return [
/**
* Secure the page behind a custom policy.
*/
'authorization' => false,
```php
FilamentLaravelLogPlugin::make()
->navigationGroup('System Tools')
->navigationLabel('Logs')
->navigationIcon('heroicon-o-bug-ant')
->navigationSort(1)
->slug('logs')
```

/**
* The directory(ies) containing the log files.
*/
'logsDir' => [
storage_path('logs'),
],
### Customizing the log search

/**
* Files to ignore when searching for log files.
* Accepts wildcards eg: *.log
*/
'exclude' => [
//
],
```php
FilamentLaravelLogPlugin::make()
->logDirs([
storage_path('logs'), // The default value
])
->excludedFilesPatterns([
'*2023*'
])
```

/**
* Navigation group.
*/
'navigationGroup' => 'System',
### Authorization
If you would like to prevent certain users from accessing the logs page, you should add a `authorize` callback in the FilamentLaravelLogPlugin chain.
Customizing the editor's appearance

/**
* Navigation sort.
*/
'navigationSort' => 1,
Publish the config file:

/**
* Navigation icon.
*/
'navigationIcon' => 'heroicon-o-document-text',
```bash
php artisan vendor:publish --tag="log-config"
```

/**
* Navigation label.
*/
'navigationLabel' => 'Logs',
This is the contents of the published config file:

/**
* Navigation slug.
*/
'slug' => 'system-logs',
```php
<?php

return [
/**
* Maximum amount of lines that editor will render.
*/
Expand All @@ -114,41 +105,6 @@ return [
];
```

## Authorization
If you would like to prevent certain users from accessing your page, you should enable `authorization` in config
```php
// config/filament-laravel-log.php

<?php
return [
/**
* Secure the page behind a custom policy.
*/
'authorization' => true,
];
```
and register an authorization callback inside of a `ServiceProvider::boot()` method.


```php
// app/Providers/AppServiceProvider.php

<?php

public function boot()
{
ViewLog::can(function (User $user) {
return $user->role === Role::Admin;
});
}
```

## Testing

```bash
composer test
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
Expand All @@ -164,10 +120,14 @@ Please review [our security policy](../../security/policy) on how to report secu
## Credits

- [Saade](https://github.com/saade)
- [Laravel Forge](https://forge.laravel.com) - for the syntax highlighting theme
- [ryangjchandler's Filament Log](https://github.com/ryangjchandler/filament-log) - based of for the authorization and multiple log files feature
- [All Contributors](../../contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

<p align="center">
<a href="https://github.com/sponsors/saade">
<img src="https://raw.githubusercontent.com/saade/filament-laravel-log/3.x/art/sponsor.png" alt="Sponsor Saade" style="width: 100%; max-width: 800px;" />
</a>
</p>
Binary file added art/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed art/preview.jpeg
Binary file not shown.
Binary file added art/sponsor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions bin/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import esbuild from 'esbuild'

const isDev = process.argv.includes('--dev')

async function compile(options) {
const context = await esbuild.context(options)

if (isDev) {
await context.watch()
} else {
await context.rebuild()
await context.dispose()
}
}

const defaultOptions = {
define: {
'process.env.NODE_ENV': isDev ? `'development'` : `'production'`,
},
bundle: true,
mainFields: ['module', 'main'],
platform: 'neutral',
sourcemap: isDev ? 'inline' : false,
sourcesContent: isDev,
treeShaking: true,
target: ['es2020'],
minify: !isDev,
plugins: [{
name: 'watchPlugin',
setup: function (build) {
build.onStart(() => {
console.log(`Build started at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`)
})

build.onEnd((result) => {
if (result.errors.length > 0) {
console.log(`Build failed at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`, result.errors)
} else {
console.log(`Build finished at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`)
}
})
}
}],
}

compile({
...defaultOptions,
entryPoints: ['./resources/js/index.js'],
outfile: './resources/dist/filament-laravel-log.js',
})
31 changes: 19 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"filament-laravel-log"
],
"homepage": "https://github.com/saade/filament-laravel-log",
"support": {
"issues": "https://github.com/saade/filament-laravel-log/issues",
"source": "https://github.com/saade/filament-laravel-log"
},
"license": "MIT",
"authors": [
{
Expand All @@ -16,37 +20,40 @@
}
],
"require": {
"php": "^8.0",
"filament/filament": "^2.10",
"illuminate/contracts": "^9.0|^10.0",
"spatie/laravel-package-tools": "^1.9.2"
"php": "^8.1",
"filament/filament": "^3.0",
"illuminate/contracts": "^10.0",
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
"nunomaduro/collision": "^6.0",
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.9",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^7.0|^8.0",
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-laravel": "^1.1",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-arch": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.6",
"spatie/laravel-ray": "^1.26"
},
"autoload": {
"psr-4": {
"Saade\\FilamentLaravelLog\\": "src"
"Saade\\FilamentLaravelLog\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Saade\\FilamentLaravelLog\\Tests\\": "tests"
"Saade\\FilamentLaravelLog\\Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage"
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint"
},
"config": {
"sort-packages": true,
Expand Down
Loading

0 comments on commit fa544ca

Please sign in to comment.