Appite neloguje exceptions

Čamo
Člen | 798
+
0
-

Mám v ruke jedne projekt v Appite. V bootstrap.php sa nastavuje Tracy debugger ale Tracy na produkcii ani na locale vôbec neloguje chyby do súbodu.
Bootstrap vyzerá takto:

<?php declare(strict_types=1);

namespace App;

use Nette\Configurator;
use PavolEichler\Environments\Environments;

// DEFAULT SETTINGS
$environments = new Environments(array(
    'tempDir' => __DIR__ . '/../temp',
    'logDir' => __DIR__ . '/../log',
    'appDir' => __DIR__,
    'configDir' => __DIR__ . '/config',
    'debugMode' => false,
    'forbidden' => false
));

// locale
$environments->setEnvironment(array(
    Environments::HOSTNAME => 'DESKTOP-UHM57UB'
), array(
    'config' => array('/local/@vlado.neon'),
    'debugMode' => false  // Bey ohladu na to ci je true alebo false neloguje nič resp. doslova niekedy to chybu zaloguje ale väčšinou nie.
));

// production
$environments->setEnvironment(array(
    Environments::HTTP_HOST => 'portal-api.lurity.com'
), array(
    'config' => array('/local/@portal-api.lurity.com.neon'),
    'debugMode' => false
));

$http_host = $_SERVER['HTTP_HOST'];
$http_path_image = '/data/products/';
$http_path_video = '/data/video/converted/';

if (gethostname() == 'DESKTOP-UHM57UB') {
	define('SERVER', 'devel');
	define('AUTH_HEADER', 'Authorization');

	define('MEDIA_URL', 'http://'.$http_host . $http_path_image);
	define('MEDIA_URL_VIDEO', 'http://'.$http_host . $http_path_video);
} else {
  define('SERVER', 'production');
  define('AUTH_HEADER', 'Authorization');

  define('MEDIA_URL', 'https://'.$http_host . $http_path_image);
  define('MEDIA_URL_VIDEO', 'https://'.$http_host . $http_path_video);
}

\Tracy\Debugger::$showBar = FALSE;

$environment = $environments->getCurrentEnvironment();

$configurator = new Configurator;

$configurator->setTimeZone('Europe/Prague');
$configurator->setTempDirectory($environment->tempDir);

$configurator->createRobotLoader()
    ->addDirectory(__DIR__)
    ->register();

// Enable Nette Debugger for error visualisation & logging
$configurator->setDebugMode($environment->debugMode);
$configurator->enableTracy($environment->logDir);

//error_reporting(~E_USER_DEPRECATED);
error_reporting(~E_ALL);


// Enable RobotLoader - this will load all classes automatically
$configurator->createRobotLoader()
    ->addDirectory($environment->appDir)
    ->register();

// Create Dependency Injection container from config.neon file
$configurator->addConfig($environment->appDir . '/config/config.neon');

// Add the local environment configuration file
foreach (is_array($environment->config) ? $environment->config : array($environment->config) as $config) {
  $configurator->addConfig($environment->configDir . $config);
}

$container = $configurator->createContainer();

return $container;

Editoval Čamo (24. 10. 2021 12:39)

Felix
Nette Core | 1196
+
0
-

Ahoj. Ukazal by jsi mi neon a jak tam registrujes a nastavujed apitte? Z toho pozname jak to tam mas.

Milo
Nette Core | 1283
+
+2
-

A tohle error_reporting(~E_ALL); je tam z jakého důvodu?

Čamo
Člen | 798
+
0
-

Ďakujem, neon vyzerá takto:

parameters:
    dataDir: %appDir%/../data

    locales:
        available: ['sk', 'en', 'cz']

dibi:
	username: xxxx
	host: xxxxxxxxxxx
	database: xxxxx
	password: xxxxxxxxxx
	lazy: TRUE
	autowired: FALSE

globalDb:
	username: xxxxxxx
	host: xxxxxxxxxx
	database: xxxxxxxxx
	password: xxxxxxxx
	lazy: TRUE
	autowired: FALSE

extensions:
	dibi: Dibi\Bridges\Nette\DibiExtension22
	globalDb: Dibi\Bridges\Nette\DibiExtension22

	middlewares: Contributte\Middlewares\DI\MiddlewaresExtension
	resource: Contributte\DI\Extension\ResourceExtension
	api: Apitte\Core\DI\ApiExtension

middlewares:
	middlewares:
		- Contributte\Middlewares\TracyMiddleware
		- Contributte\Middlewares\AutoBasePathMiddleware
		- App\Middlewares\ApiKeyAuthenticationMiddleware
		- Apitte\Middlewares\ApiMiddleware

api:
	catchException: true # set to false to see exceptions in debug mode
	debug: %debugMode%
	plugins:
		Apitte\Core\DI\Plugin\CoreDecoratorPlugin:
		Apitte\Core\DI\Plugin\CoreMappingPlugin:
		Apitte\Middlewares\DI\MiddlewaresPlugin:
		Apitte\Negotiation\DI\NegotiationPlugin:
			unification: on
		Apitte\Debug\DI\DebugPlugin:
		#Apitte\OpenApi\DI\OpenApiPlugin:
		#Apitte\Debug\DI\DebugPlugin:
			#debug: %debugMode%
				#panel: %debugMode%
				#negotiation: %debugMode%

resource:
	resources:
		App\Controllers\:
			paths: [%appDir%/Controllers]
			decorator:
				inject: true
		App\Middlewares\:
			paths: [%appDir%/Middlewares]
			decorator:
				inject: true

session:
	autoStart: true
	expiration: 1 days

php:
	date.timezone: Europe/Prague

tracy:
    email: xxxxx@xxxxx.xx

services:
	#cache.storage: Nette\Caching\Storages\FileStorage(%tempDir%)
	cache.storage: Nette\Caching\Storages\SQLiteStorage('%tempDir%/cache.db')
	translator: Models\Services\Translator(@dibi.connection, @globalDb.connection, Nette\Caching\Cache(namespace: 'translations'), @session)

includes:
    - models.neon

@Milo error_reporting(~E_ALL); tam bolo pred tým. Malo by to ísť preč?

Felix
Nette Core | 1196
+
0
-

Jeste prosim composer.json. Staci idealne contributte+apitte. At vim o jakou verzi se jedna.

Milo
Nette Core | 1283
+
0
-

@Milo error_reporting(~E_ALL); tam bolo pred tým. Malo by to ísť preč?

Podle mě ano.

  • $configurator->enableTracy($environment->logDir); – zapneš Tracy, ta si ponastavuje error reporting
  • error_reporting(~E_ALL); a ty pak oznámíš, že žádné chyby nechceš reportovat (negace E_ALL).

Tracy respektuje aktuální hodnotu z error_reporting(), pokud není $scream = true. To je užitečné, pokud chceš například vypnout E_USER_DEPRECATED hlášky.

Čamo
Člen | 798
+
0
-

composer.json

{
  "name": "nette/web-project",
  "description": "Nette: Standard Web Project",
  "keywords": [
    "nette"
  ],
  "type": "project",
  "license": [
    "MIT",
    "BSD-3-Clause",
    "GPL-2.0",
    "GPL-3.0"
  ],
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/xrainman/database"
    },
    {
      "type": "vcs",
      "url": "https://github.com/xrainman/environments"
    }
  ],
  "require": {
    "pavoleichler/database": "dev-master",
    "pavoleichler/environments": "dev-master",
    "php": ">= 7.2.0",
    "contributte/bootstrap": "^0.4.0",
    "contributte/http": "^0.3.0",
    "contributte/tracy": "^0.4.0",
    "contributte/di": "^0.4.0",
    "apitte/fullstack": "^0.6.0",

    "nette/robot-loader": "~3.3.0",
    "adhocore/jwt": "^1.1",
    "firebase/php-jwt": "^5.2",
    "ext-json": "*",
    "google/auth": "^1.14",
    "google/apiclient": "^2.8",
    "braintree/braintree_php": "^6.4",
    "cloudinary/cloudinary_php": "^2.1",
    "php-ffmpeg/php-ffmpeg": "^0.17.0",
    "nette/utils": "3.0.3"
  },
  "minimum-stability": "dev",
  "prefer-stable": true
}
Čamo
Člen | 798
+
0
-

Nejaký ďalší nápad prečo to nefunguje?

Čamo
Člen | 798
+
0
-

Milo napsal(a):

@Milo error_reporting(~E_ALL); tam bolo pred tým. Malo by to ísť preč?

Podle mě ano.

  • $configurator->enableTracy($environment->logDir); – zapneš Tracy, ta si ponastavuje error reporting
  • error_reporting(~E_ALL); a ty pak oznámíš, že žádné chyby nechceš reportovat (negace E_ALL).

Tracy respektuje aktuální hodnotu z error_reporting(), pokud není $scream = true. To je užitečné, pokud chceš například vypnout E_USER_DEPRECATED hlášky.

Aj keď to zakomentujem nič sa nezmení. Žiadne exceptions to neloguje.

Felix
Nette Core | 1196
+
0
-

Jeste se zeptam.

  1. Pri debugMode=true a catchException=false chybu vidis?
  2. Kde presne se ta chyba vyhazuje? Napriklad v controlleru? Kdyz tam manualne udelas throw new RuntimeException('foo')?
Čamo
Člen | 798
+
0
-

@Felix Pri debugMode=true a catchException=false vidím Tracy exception na frontende. Ale ja potrebujem aby sa zalogovala na backende.
Skúsim to vykuchať a urobiť example repo na Githube.

Editoval Čamo (1. 11. 2021 14:34)

Čamo
Člen | 798
+
0
-

Spravil som github repozitár s kostrou toho projektu: https://github.com/…apitte-tracy

V bootstrap.php treba zmeniť DESKTOP-UHM57UB na „computer name“ vašeho PC, alebo možno to nejakou podmienkou preskočiť. Snažil som sa to čo najvernejšie zachovať ako to je spravené.

Keď sa potom v TestControllery zavolá napr. neexistujúca metoda tak sa nič nezaloguje. Api vráti error Application encountered an internal error.

Editoval Čamo (1. 11. 2021 16:47)

Felix
Nette Core | 1196
+
0
-

Ahoj, diky, mas tam PR s funkcnim logovanim. Jeste jsem u toho upgradoval apitte na posledni verzi v0.7.

Čamo
Člen | 798
+
0
-

@Felix vďaka, som zvedavý v čom bol problém.