Skip to content

Commit

Permalink
feat: add option to hide stack trace button
Browse files Browse the repository at this point in the history
  • Loading branch information
czernika committed Apr 22, 2024
1 parent 526ae73 commit 5e108b0
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 67 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ Also you can disable registration of menu item and route completely but you have
## Known issues

- Works only with "laravelish" logs - if you put for example `worker.log` which created by process managers like supervisor or pm2 it will not be recognized correctly
- 414 Error may occur when calling stack trace modal

## Roadmap

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "czernika/orchid-log-viewer",
"description": "Manage your Laravel app logs within Orchid admin panel ",
"license": "MIT",
"version": "1.0.8",
"version": "1.0.9",
"authors": [
{
"name": "Aliakseyenka Ihar",
Expand Down
92 changes: 44 additions & 48 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions config/orchid-log.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,29 @@
|
*/
'text_column_width' => 700, // px

/*
|--------------------------------------------------------------------------
| Stack trace column
|--------------------------------------------------------------------------
|
| Show modal toggle to view stack trace or not. It may throw 414 error which
| may be annoying for end-users, so ypu may want to disable it or shorten
|
*/
'stack' => [
'render' => true,

/*
|--------------------------------------------------------------------------
| Limit stack trace message
|--------------------------------------------------------------------------
|
| Set "0" if you wish to keep full length trace
|
*/
'limit' => 1000, // characters
],
],

/*
Expand Down
8 changes: 4 additions & 4 deletions src/Layouts/OrchidLogTableLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OrchidLogTableLayout extends Table

protected function levelColumn(): TD
{
return TD::make('level', trans('orchid-log::messages.layout.stack'))
return TD::make('level', trans('orchid-log::messages.layout.level'))
->render(function (LogData $log) {
return Blade::render(
/** translators: 1 - Bootstrap icon name; 2 - log level; 3 - Bootstrap text-color class */
Expand Down Expand Up @@ -71,11 +71,11 @@ protected function dateColumn(): TD

protected function columns(): iterable
{
return [
return array_filter([
$this->levelColumn(),
$this->textColumn(),
$this->stackTraceColumn(),
config('orchid-log.table.stack.render', true) ? $this->stackTraceColumn() : null,
$this->dateColumn(),
];
]);
}
}
39 changes: 25 additions & 14 deletions src/Screen/OrchidLogListScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Orchid\Screen\Screen;
use Orchid\Support\Color;
use Orchid\Support\Facades\Layout;
use Illuminate\Support\Str;
use Illuminate\Support\Stringable;

class OrchidLogListScreen extends Screen
{
Expand Down Expand Up @@ -66,27 +68,36 @@ public function commandBar()

public function layout(): iterable
{
return [
return array_filter([
OrchidLogFilterLayout::class,
Layout::modal('logModal', [
Layout::rows([
TextArea::make('stack')
->readonly(false) // TODO make an option
->rows(40),
]),
])
->async('asyncGetLog')
->withoutApplyButton()
->title(trans('orchid-log::messages.layout.stack'))
->size(Modal::SIZE_LG),

config('orchid-log.table.stack.render', true) ?
Layout::modal('logModal', [
Layout::rows([
TextArea::make('stack')
->readonly(false) // TODO make an option
->rows(40),
]),
])
->async('asyncGetLog')
->withoutApplyButton()
->title(trans('orchid-log::messages.layout.stack'))
->size(Modal::SIZE_LG) :
null,

LogManager::layout(),
];
]);
}

public function asyncGetLog(string $stack): array
{
return compact('stack');
return [
'stack' => Str::of($stack)
->when((int) config('orchid-log.table.stack.limit') > 0, function (Stringable $val) {
return $val->limit(config('orchid-log.table.stack.limit', 400));
})
->value(),
];
}

protected function canSeeCleanBtn(): bool
Expand Down

0 comments on commit 5e108b0

Please sign in to comment.