/home/techb158/ileadtechnology.com/SSM/vendor/laravel/telescope/src
Edit: /home/techb158/ileadtechnology.com/SSM/vendor/laravel/telescope/src/Telescope.php (17472B)
runningInConsole() && ! in_array(
$_SERVER['argv'][1] ?? null,
array_merge([
// 'migrate',
'migrate:rollback',
'migrate:fresh',
// 'migrate:refresh',
'migrate:reset',
'migrate:install',
'package:discover',
'queue:listen',
'queue:work',
'horizon',
'horizon:work',
'horizon:supervisor',
], config('telescope.ignoreCommands', []), config('telescope.ignore_commands', []))
);
}
/**
* Determine if the application is handling an approved request.
*
* @param \Illuminate\Foundation\Application $app
* @return bool
*/
protected static function handlingApprovedRequest($app)
{
return ! $app->runningInConsole() && ! $app['request']->is(
array_merge([
config('telescope.path').'*',
'telescope-api*',
'vendor/telescope*',
'horizon*',
'vendor/horizon*',
], config('telescope.ignore_paths', []))
);
}
/**
* Start recording entries.
*
* @return void
*/
public static function startRecording()
{
app(EntriesRepository::class)->loadMonitoredTags();
static::$shouldRecord = ! cache('telescope:pause-recording');
}
/**
* Stop recording entries.
*
* @return void
*/
public static function stopRecording()
{
static::$shouldRecord = false;
}
/**
* Execute the given callback without recording Telescope entries.
*
* @param callable $callback
* @return void
*/
public static function withoutRecording($callback)
{
$shouldRecord = static::$shouldRecord;
static::$shouldRecord = false;
call_user_func($callback);
static::$shouldRecord = $shouldRecord;
}
/**
* Determine if Telescope is recording.
*
* @return bool
*/
public static function isRecording()
{
return static::$shouldRecord && ! app('events') instanceof EventFake;
}
/**
* Record the given entry.
*
* @param string $type
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
protected static function record(string $type, IncomingEntry $entry)
{
if (! static::isRecording()) {
return;
}
$entry->type($type)->tags(Arr::collapse(array_map(function ($tagCallback) use ($entry) {
return $tagCallback($entry);
}, static::$tagUsing)));
try {
if (Auth::hasResolvedGuards() && Auth::hasUser()) {
$entry->user(Auth::user());
}
} catch (Throwable $e) {
// Do nothing.
}
static::withoutRecording(function () use ($entry) {
if (collect(static::$filterUsing)->every->__invoke($entry)) {
static::$entriesQueue[] = $entry;
}
if (static::$afterRecordingHook) {
call_user_func(static::$afterRecordingHook, new static);
}
});
}
/**
* Record the given entry update.
*
* @param \Laravel\Telescope\EntryUpdate $update
* @return void
*/
public static function recordUpdate(EntryUpdate $update)
{
if (static::$shouldRecord) {
static::$updatesQueue[] = $update;
}
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordCache(IncomingEntry $entry)
{
static::record(EntryType::CACHE, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordCommand(IncomingEntry $entry)
{
static::record(EntryType::COMMAND, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordDump(IncomingEntry $entry)
{
static::record(EntryType::DUMP, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordEvent(IncomingEntry $entry)
{
static::record(EntryType::EVENT, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordException(IncomingEntry $entry)
{
static::record(EntryType::EXCEPTION, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordGate(IncomingEntry $entry)
{
static::record(EntryType::GATE, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordJob($entry)
{
static::record(EntryType::JOB, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordLog(IncomingEntry $entry)
{
static::record(EntryType::LOG, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordMail(IncomingEntry $entry)
{
static::record(EntryType::MAIL, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordNotification($entry)
{
static::record(EntryType::NOTIFICATION, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordQuery(IncomingEntry $entry)
{
static::record(EntryType::QUERY, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordModelEvent(IncomingEntry $entry)
{
static::record(EntryType::MODEL, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordRedis(IncomingEntry $entry)
{
static::record(EntryType::REDIS, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordRequest(IncomingEntry $entry)
{
static::record(EntryType::REQUEST, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordScheduledCommand(IncomingEntry $entry)
{
static::record(EntryType::SCHEDULED_TASK, $entry);
}
/**
* Record the given entry.
*
* @param \Laravel\Telescope\IncomingEntry $entry
* @return void
*/
public static function recordView(IncomingEntry $entry)
{
static::record(EntryType::VIEW, $entry);
}
/**
* Flush all entries in the queue.
*
* @return static
*/
public static function flushEntries()
{
static::$entriesQueue = [];
return new static;
}
/**
* Record the given exception.
*
* @param \Throwable|\Exception $e
* @param array $tags
* @return void
*/
public static function catch($e, $tags = [])
{
if ($e instanceof Throwable && ! $e instanceof Exception) {
$e = new FatalThrowableError($e);
}
event(new MessageLogged('error', $e->getMessage(), [
'exception' => $e,
'telescope' => $tags,
]));
}
/**
* Set the callback that filters the entries that should be recorded.
*
* @param \Closure $callback
* @return static
*/
public static function filter(Closure $callback)
{
static::$filterUsing[] = $callback;
return new static;
}
/**
* Set the callback that filters the batches that should be recorded.
*
* @param \Closure $callback
* @return static
*/
public static function filterBatch(Closure $callback)
{
static::$filterBatchUsing[] = $callback;
return new static;
}
/**
* Set the callback that will be executed after an entry is recorded in the queue.
*
* @param \Closure $callback
* @return static
*/
public static function afterRecording(Closure $callback)
{
static::$afterRecordingHook = $callback;
return new static;
}
/**
* Add a callback that adds tags to the record.
*
* @param \Closure $callback
* @return static
*/
public static function tag(Closure $callback)
{
static::$tagUsing[] = $callback;
return new static;
}
/**
* Store the queued entries and flush the queue.
*
* @param \Laravel\Telescope\Contracts\EntriesRepository $storage
* @return void
*/
public static function store(EntriesRepository $storage)
{
if (empty(static::$entriesQueue) && empty(static::$updatesQueue)) {
return;
}
if (! collect(static::$filterBatchUsing)->every->__invoke(collect(static::$entriesQueue))) {
static::flushEntries();
}
try {
$batchId = Str::orderedUuid()->toString();
$storage->store(static::collectEntries($batchId));
$storage->update(static::collectUpdates($batchId));
if ($storage instanceof TerminableRepository) {
$storage->terminate();
}
} catch (Exception $e) {
app(ExceptionHandler::class)->report($e);
}
static::$entriesQueue = [];
static::$updatesQueue = [];
}
/**
* Collect the entries for storage.
*
* @param string $batchId
* @return \Illuminate\Support\Collection
*/
protected static function collectEntries($batchId)
{
return collect(static::$entriesQueue)
->each(function ($entry) use ($batchId) {
$entry->batchId($batchId);
if ($entry->isDump()) {
$entry->assignEntryPointFromBatch(static::$entriesQueue);
}
});
}
/**
* Collect the updated entries for storage.
*
* @param string $batchId
* @return \Illuminate\Support\Collection
*/
protected static function collectUpdates($batchId)
{
return collect(static::$updatesQueue)
->each(function ($entry) use ($batchId) {
$entry->change(['updated_batch_id' => $batchId]);
});
}
/**
* Hide the given request header.
*
* @param array $headers
* @return static
*/
public static function hideRequestHeaders(array $headers)
{
static::$hiddenRequestHeaders = array_merge(
static::$hiddenRequestHeaders,
$headers
);
return new static;
}
/**
* Hide the given request parameters.
*
* @param array $attributes
* @return static
*/
public static function hideRequestParameters(array $attributes)
{
static::$hiddenRequestParameters = array_merge(
static::$hiddenRequestParameters,
$attributes
);
return new static;
}
/**
* Hide the given response parameters.
*
* @param array $attributes
* @return static
*/
public static function hideResponseParameters(array $attributes)
{
static::$hiddenResponseParameters = array_merge(
static::$hiddenResponseParameters,
$attributes
);
return new static;
}
/**
* Specifies that Telescope should record events fired by Laravel.
*
* @return static
*/
public static function recordFrameworkEvents()
{
static::$ignoreFrameworkEvents = false;
return new static;
}
/**
* Specifies that Telescope should use the dark theme.
*
* @return static
*/
public static function night()
{
static::$useDarkTheme = true;
return new static;
}
/**
* Get the default JavaScript variables for Telescope.
*
* @return array
*/
public static function scriptVariables()
{
return [
'path' => config('telescope.path'),
'timezone' => config('app.timezone'),
'recording' => ! cache('telescope:pause-recording'),
];
}
/**
* Configure Telescope to not register its migrations.
*
* @return static
*/
public static function ignoreMigrations()
{
static::$runsMigrations = false;
return new static;
}
/**
* Check if assets are up-to-date.
*
* @return bool
*
* @throws \RuntimeException
*/
public static function assetsAreCurrent()
{
$publishedPath = public_path('vendor/telescope/mix-manifest.json');
if (! File::exists($publishedPath)) {
throw new RuntimeException('The Telescope assets are not published. Please run: php artisan telescope:publish');
}
return File::get($publishedPath) === File::get(__DIR__.'/../public/mix-manifest.json');
}
}