No known key found for this signature in database
GPG Key ID: BDE6667570EADBD5
4 changed files with 213 additions and 0 deletions
-
143app/Http/Controllers/DebugController.php
-
1config/logging.php
-
68resources/views/debug.twig
-
1routes/web.php
@ -0,0 +1,143 @@ |
|||
<?php |
|||
/* |
|||
* DebugController.php |
|||
* Copyright (c) 2021 james@firefly-iii.org |
|||
* |
|||
* This file is part of the Firefly III Data Importer |
|||
* (https://github.com/firefly-iii/data-importer). |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU Affero General Public License as |
|||
* published by the Free Software Foundation, either version 3 of the |
|||
* License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU Affero General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU Affero General Public License |
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
namespace App\Http\Controllers; |
|||
|
|||
use Artisan; |
|||
use Carbon\Carbon; |
|||
use DB; |
|||
use Exception; |
|||
use FireflyConfig; |
|||
use FireflyIII\Exceptions\FireflyException; |
|||
use FireflyIII\Http\Middleware\IsDemoUser; |
|||
use FireflyIII\Support\Http\Controllers\GetConfigurationData; |
|||
use Illuminate\Contracts\View\Factory; |
|||
use Illuminate\Http\RedirectResponse; |
|||
use Illuminate\Http\Request; |
|||
use Illuminate\Routing\Redirector; |
|||
use Illuminate\Routing\Route; |
|||
use Illuminate\View\View; |
|||
use Log; |
|||
use Monolog\Handler\RotatingFileHandler; |
|||
use Route as RouteFacade; |
|||
|
|||
|
|||
class DebugController extends Controller |
|||
{ |
|||
/** |
|||
* Show debug info. |
|||
* |
|||
* @param Request $request |
|||
* |
|||
* @return Factory|View |
|||
* @throws FireflyException |
|||
*/ |
|||
public function index(Request $request) |
|||
{ |
|||
$search = ['~', '#']; |
|||
$replace = ['\~', '# ']; |
|||
|
|||
$now = Carbon::now()->format('Y-m-d H:i:s e'); |
|||
$phpVersion = str_replace($search, $replace, PHP_VERSION); |
|||
$phpOs = str_replace($search, $replace, PHP_OS); |
|||
$interface = PHP_SAPI; |
|||
$userAgent = $request->header('user-agent'); |
|||
$trustedProxies = config('importer.trusted_proxies'); |
|||
$displayErrors = ini_get('display_errors'); |
|||
$errorReporting = $this->errorReporting((int)ini_get('error_reporting')); |
|||
$appEnv = config('app.env'); |
|||
$appDebug = var_export(config('app.debug'), true); |
|||
$logChannel = config('logging.default'); |
|||
$appLogLevel = config('logging.level'); |
|||
$cacheDriver = config('cache.default'); |
|||
$bcscale = bcscale(); |
|||
$tz = env('TZ'); |
|||
$isDocker = env('IS_DOCKER', false); |
|||
|
|||
// get latest log file:
|
|||
$logger = Log::driver(); |
|||
$handlers = $logger->getHandlers(); |
|||
$logContent = ''; |
|||
foreach ($handlers as $handler) { |
|||
if ($handler instanceof RotatingFileHandler) { |
|||
$logFile = $handler->getUrl(); |
|||
if (null !== $logFile) { |
|||
try { |
|||
$logContent = file_get_contents($logFile); |
|||
|
|||
} catch (Exception $e) { // @phpstan-ignore-line
|
|||
// @ignoreException
|
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
if ('' !== $logContent) { |
|||
// last few lines
|
|||
$logContent = 'Truncated from this point <----|' . substr($logContent, -8192); |
|||
} |
|||
|
|||
return view( |
|||
'debug', |
|||
compact( |
|||
'phpVersion', |
|||
'appEnv', |
|||
'appDebug', |
|||
'logChannel', |
|||
'tz', |
|||
'appLogLevel', |
|||
'now', |
|||
'bcscale', |
|||
'userAgent', |
|||
'displayErrors', |
|||
'errorReporting', |
|||
'phpOs', |
|||
'interface', |
|||
'logContent', |
|||
'cacheDriver', |
|||
'trustedProxies', |
|||
'isDocker' |
|||
) |
|||
); |
|||
} |
|||
/** |
|||
* Some common combinations. |
|||
* |
|||
* @param int $value |
|||
* |
|||
* @return string |
|||
*/ |
|||
protected function errorReporting(int $value): string // get configuration
|
|||
{ |
|||
$array = [ |
|||
-1 => 'ALL errors', |
|||
E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED => 'E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED', |
|||
E_ALL => 'E_ALL', |
|||
E_ALL & ~E_DEPRECATED & ~E_STRICT => 'E_ALL & ~E_DEPRECATED & ~E_STRICT', |
|||
E_ALL & ~E_NOTICE => 'E_ALL & ~E_NOTICE', |
|||
E_ALL & ~E_NOTICE & ~E_STRICT => 'E_ALL & ~E_NOTICE & ~E_STRICT', |
|||
E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR => 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR', |
|||
]; |
|||
|
|||
return $array[$value] ?? (string)$value; |
|||
} |
|||
} |
@ -0,0 +1,68 @@ |
|||
<html> |
|||
<head> |
|||
<title>FIDI Debug</title> |
|||
</head> |
|||
<body> |
|||
|
|||
<p style="font-family:Arial, Arial, Helvetica, sans-serif;font-size:12pt;width:600px;"> |
|||
Firefly III data importer debug page |
|||
</p> |
|||
<p style="font-family:Arial, Arial, Helvetica, sans-serif;font-size:12pt;width:600px;"> |
|||
Copy and paste this textarea in your issue. |
|||
</p> |
|||
<textarea rows="30" cols="100" name="debug_info" id="debug_info" style="font-family:Menlo, Monaco, Consolas, monospace;font-size:8pt;"> |
|||
Debug information generated at {{ now }} for Firefly III Data Importer version **{{ config('importer.version') }}**. |
|||
|
|||
| Scope | Version | |
|||
| --- | --- | |
|||
| FIDI | {{ config('importer.version') }} | |
|||
| PHP | {{ phpVersion }} | |
|||
| Host | {{ phpOs }} | |
|||
|
|||
| System info | Value | |
|||
| --- | --- | |
|||
| Using docker? | {% if isDocker %}true{% else %}false{% endif %} | |
|||
| System TZ | {{ tz }} | |
|||
| Browser TZ | [BrowserTZ] | |
|||
| App environment | {{ appEnv }} | |
|||
| App debug mode | {{ appDebug }} | |
|||
| App cache driver | {{ cacheDriver }} | |
|||
| App logging | {{ appLogLevel }}, {{ logChannel }} | |
|||
| Display errors | {{ displayErrors }} | |
|||
| Error reporting | {{ errorReporting }} | |
|||
| Interface | {{ interface }} | |
|||
| BCscale | {{ bcscale }} | |
|||
| Trusted proxies (.env) | {{ trustedProxies }} | |
|||
|
|||
| User info | Value | |
|||
| --- | --- | |
|||
| User agent | {{ userAgent }} | |
|||
</textarea> |
|||
<script type="text/javascript" nonce="{{ JS_NONCE }}"> |
|||
var textArea = document.getElementById('debug_info'); |
|||
var text = textArea.value; |
|||
var timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; |
|||
text = text.replace('[BrowserTZ]', timeZone); |
|||
textArea.value = text; |
|||
</script> |
|||
|
|||
<p style="font-family:Arial, Arial, Helvetica, sans-serif;font-size:12pt;width:600px;color:#a00;"> |
|||
<a href="{{ route('index') }}">Back to index</a> |
|||
</p> |
|||
|
|||
<p style="font-family:Arial, Arial, Helvetica, sans-serif;font-size:12pt;width:600px;color:#a00;"> |
|||
Extra info. Do not share this lightly! |
|||
</p> |
|||
|
|||
<textarea rows="30" cols="100" name="log_info" style="font-family:Menlo, Monaco, Consolas, monospace;font-size:7pt;"> |
|||
``` |
|||
{{ logContent }} |
|||
``` |
|||
</textarea> |
|||
|
|||
<p style="font-family:Arial, Arial, Helvetica, sans-serif;font-size:12pt;width:600px;color:#a00;"> |
|||
<a href="{{ route('index') }}">Back to index</a> |
|||
</p> |
|||
|
|||
</body> |
|||
</html> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue