Uploaded From CV. Swandhana Server
This commit is contained in:
No files matched your search
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Arcanedev\LogViewer\Commands;
|
||||
|
||||
use Arcanedev\LogViewer\Contracts\Utilities\LogChecker as LogCheckerContract;
|
||||
|
||||
/**
|
||||
* Class CheckCommand
|
||||
*
|
||||
* @author ARCANEDEV <[email protected]>
|
||||
*/
|
||||
class CheckCommand extends Command
|
||||
{
|
||||
/* -----------------------------------------------------------------
|
||||
| Properties
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'log-viewer:check';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check all LogViewer requirements.';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'log-viewer:check';
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
| Getter & Setters
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the Log Checker instance.
|
||||
*
|
||||
* @return \Arcanedev\LogViewer\Contracts\Utilities\LogChecker
|
||||
*/
|
||||
protected function getChecker()
|
||||
{
|
||||
return $this->laravel[LogCheckerContract::class];
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
| Main Methods
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->displayLogViewer();
|
||||
$this->displayRequirements();
|
||||
$this->displayMessages();
|
||||
|
||||
return static::SUCCESS;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
| Other Methods
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Display LogViewer requirements.
|
||||
*/
|
||||
private function displayRequirements()
|
||||
{
|
||||
$requirements = $this->getChecker()->requirements();
|
||||
|
||||
$this->frame('Application requirements');
|
||||
|
||||
$this->table([
|
||||
'Status', 'Message'
|
||||
], [
|
||||
[$requirements['status'], $requirements['message']]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display LogViewer messages.
|
||||
*/
|
||||
private function displayMessages()
|
||||
{
|
||||
$messages = $this->getChecker()->messages();
|
||||
|
||||
$rows = [];
|
||||
foreach ($messages['files'] as $file => $message) {
|
||||
$rows[] = [$file, $message];
|
||||
}
|
||||
|
||||
if ( ! empty($rows)) {
|
||||
$this->frame('LogViewer messages');
|
||||
$this->table(['File', 'Message'], $rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Arcanedev\LogViewer\Commands;
|
||||
|
||||
/**
|
||||
* Class ClearCommand
|
||||
*
|
||||
* @author ARCANEDEV <[email protected]>
|
||||
*/
|
||||
class ClearCommand extends Command
|
||||
{
|
||||
/* -----------------------------------------------------------------
|
||||
| Properties
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'log-viewer:clear';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Clear all generated log files';
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
| Main Methods
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
if ($this->confirm('This will delete all the log files, Do you wish to continue?')) {
|
||||
$this->logViewer->clear();
|
||||
$this->info('Successfully cleared the logs!');
|
||||
}
|
||||
|
||||
return static::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Arcanedev\LogViewer\Commands;
|
||||
|
||||
use Arcanedev\LogViewer\Contracts\LogViewer as LogViewerContract;
|
||||
use Arcanedev\Support\Console\Command as BaseCommand;
|
||||
|
||||
/**
|
||||
* Class Command
|
||||
*
|
||||
* @author ARCANEDEV <[email protected]>
|
||||
*/
|
||||
abstract class Command extends BaseCommand
|
||||
{
|
||||
/* -----------------------------------------------------------------
|
||||
| Properties
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @var \Arcanedev\LogViewer\Contracts\LogViewer */
|
||||
protected $logViewer;
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
| Constructor
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create the command instance.
|
||||
*
|
||||
* @param \Arcanedev\LogViewer\Contracts\LogViewer $logViewer
|
||||
*/
|
||||
public function __construct(LogViewerContract $logViewer)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->logViewer = $logViewer;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
| Other Methods
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Display LogViewer Logo and Copyrights.
|
||||
*/
|
||||
protected function displayLogViewer()
|
||||
{
|
||||
// LOGO
|
||||
$this->comment(' __ _ ');
|
||||
$this->comment(' / / ___ __ _/\ /(_) _____ _____ _ __ ');
|
||||
$this->comment(' / / / _ \ / _` \ \ / / |/ _ \ \ /\ / / _ \ \'__|');
|
||||
$this->comment('/ /__| (_) | (_| |\ V /| | __/\ V V / __/ | ');
|
||||
$this->comment('\____/\___/ \__, | \_/ |_|\___| \_/\_/ \___|_| ');
|
||||
$this->comment(' |___/ ');
|
||||
$this->line('');
|
||||
|
||||
// Copyright
|
||||
$this->comment('Version '.$this->logViewer->version().' - Created by ARCANEDEV'.chr(169));
|
||||
$this->line('');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Arcanedev\LogViewer\Commands;
|
||||
|
||||
use Arcanedev\LogViewer\LogViewerServiceProvider;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Class PublishCommand
|
||||
*
|
||||
* @author ARCANEDEV <[email protected]>
|
||||
*/
|
||||
class PublishCommand extends Command
|
||||
{
|
||||
/* -----------------------------------------------------------------
|
||||
| Properties
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'log-viewer:publish';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Publish all LogViewer resources and config files';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'log-viewer:publish
|
||||
{--tag= : One or many tags that have assets you want to publish.}
|
||||
{--force : Overwrite any existing files.}';
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
| Main Methods
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$args = [
|
||||
'--provider' => LogViewerServiceProvider::class,
|
||||
];
|
||||
|
||||
if ((bool) $this->option('force')) {
|
||||
$args['--force'] = true;
|
||||
}
|
||||
|
||||
$args['--tag'] = [$this->option('tag')];
|
||||
|
||||
$this->displayLogViewer();
|
||||
$this->call('vendor:publish', $args);
|
||||
|
||||
return static::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['tag', 't', InputOption::VALUE_OPTIONAL, 'One or many tags that have assets you want to publish.', ''],
|
||||
['force', 'f', InputOption::VALUE_OPTIONAL, 'Overwrite any existing files.', false],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Arcanedev\LogViewer\Commands;
|
||||
|
||||
use Arcanedev\LogViewer\Tables\StatsTable;
|
||||
|
||||
/**
|
||||
* Class StatsCommand
|
||||
*
|
||||
* @author ARCANEDEV <[email protected]>
|
||||
*/
|
||||
class StatsCommand extends Command
|
||||
{
|
||||
/* -----------------------------------------------------------------
|
||||
| Properties
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'log-viewer:stats';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Display stats of all logs.';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'log-viewer:stats';
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
| Main Methods
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// Load Data
|
||||
$stats = $this->logViewer->statsTable('en');
|
||||
|
||||
$rows = $stats->rows();
|
||||
$rows[] = $this->tableSeparator();
|
||||
$rows[] = $this->prepareFooter($stats);
|
||||
|
||||
// Display Data
|
||||
$this->displayLogViewer();
|
||||
$this->table($stats->header(), $rows);
|
||||
|
||||
return static::SUCCESS;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
| Other Methods
|
||||
| -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prepare footer.
|
||||
*
|
||||
* @param \Arcanedev\LogViewer\Tables\StatsTable $stats
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function prepareFooter(StatsTable $stats)
|
||||
{
|
||||
$files = [
|
||||
'count' => count($stats->rows()).' log file(s)'
|
||||
];
|
||||
|
||||
return $files + $stats->footer();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user