From 89b959b3c92671c3e923a37c26fa3ab01fe81e32 Mon Sep 17 00:00:00 2001 From: zebardy Date: Fri, 22 Nov 2019 19:19:37 +0000 Subject: [PATCH] comment out debug printing --- app.php | 40 ++++++++-------- controllers/BaseController.php | 16 +++---- controllers/LoginController.php | 16 +++---- controllers/SystemApiController.php | 12 ++--- middleware/SessionAuthMiddleware.php | 16 +++---- routes.php | 68 ++++++++++++++-------------- 6 files changed, 84 insertions(+), 84 deletions(-) diff --git a/app.php b/app.php index 9880d673..11a27c12 100644 --- a/app.php +++ b/app.php @@ -1,7 +1,7 @@ function($container) { - $view_time_start = microtime(true); + #$view_time_start = microtime(true); #$view = new \Slim\Views\Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache'); if (!apcu_exists("views")) { @@ -72,9 +72,9 @@ $appContainer = new \Slim\Container([ $view = apcu_fetch("views"); - $fp = fopen('/config/data/sql.log', 'a'); - fwrite($fp, "!!!App - view load time : " . round((microtime(true) - $view_time_start),6) . "\n"); - fclose($fp); + #$fp = fopen('/config/data/sql.log', 'a'); + #fwrite($fp, "!!!App - view load time : " . round((microtime(true) - $view_time_start),6) . "\n"); + #fclose($fp); return $view; }, 'LoginControllerInstance' => function($container) @@ -95,11 +95,11 @@ $appContainer = new \Slim\Container([ return 'GROCY-API-KEY'; } ]); -fwrite($fp, "!!!App - Container build time in seconds: " . round((microtime(true) - $app_time_start),6) . "\n"); -$app_build_time_start = microtime(true); +#fwrite($fp, "!!!App - Container build time in seconds: " . round((microtime(true) - $app_time_start),6) . "\n"); +#$app_build_time_start = microtime(true); $app = new \Slim\App($appContainer); -fwrite($fp, "!!!App - App object build time in seconds: " . round((microtime(true) - $app_time_start),6) . "\n"); +#fwrite($fp, "!!!App - App object build time in seconds: " . round((microtime(true) - $app_time_start),6) . "\n"); #$fp = fopen('/www/data/sql.log', 'a'); #fwrite($fp, "!!!Starting up loading app\n"); @@ -109,19 +109,19 @@ fwrite($fp, "!!!App - App object build time in seconds: " . round((microtime(tru #phpinfo(); -$route_load_time_start = microtime(true); +#$route_load_time_start = microtime(true); // Load routes from separate file require_once __DIR__ . '/routes.php'; -fwrite($fp, "!!!App - Route load time in seconds: " . round((microtime(true) - $route_load_time_start),6) . "\n"); -fwrite($fp, "!!!App - App build time in seconds: " . round((microtime(true) - $app_time_start),6) . "\n"); +#fwrite($fp, "!!!App - Route load time in seconds: " . round((microtime(true) - $route_load_time_start),6) . "\n"); +#fwrite($fp, "!!!App - App build time in seconds: " . round((microtime(true) - $app_time_start),6) . "\n"); #$fp = fopen('/config/data/sql.log', 'a'); -fwrite($fp, "!!!App starting run\n"); -$run_time_start = microtime(true); +#fwrite($fp, "!!!App starting run\n"); +#$run_time_start = microtime(true); $app->run(); -fwrite($fp, "!!!App - Total run time in seconds: " . round((microtime(true) - $run_time_start),6) . "\n"); -fwrite($fp, "!!!App - Total execution time in seconds: " . round((microtime(true) - $time_start),6) . "\n"); +#fwrite($fp, "!!!App - Total run time in seconds: " . round((microtime(true) - $run_time_start),6) . "\n"); +#fwrite($fp, "!!!App - Total execution time in seconds: " . round((microtime(true) - $time_start),6) . "\n"); #fwrite($fp, "!!!APP - ini: ".print_r(ini_get_all(),TRUE)."\n"); #fwrite($fp, "!!!APP - opcache status: ".print_r(opcache_get_status(),TRUE)."\n"); #fwrite($fp, "!!!APP - opcache config: ".print_r(opcache_get_configuration(),TRUE)."\n"); -fclose($fp); +#fclose($fp); diff --git a/controllers/BaseController.php b/controllers/BaseController.php index 76dcbdc5..9b6edc6d 100644 --- a/controllers/BaseController.php +++ b/controllers/BaseController.php @@ -10,21 +10,21 @@ use \Grocy\Services\UsersService; class BaseController { public function __construct(\Slim\Container $container) { - $fp = fopen('/config/data/sql.log', 'a'); - $time_start = microtime(true); + #$fp = fopen('/config/data/sql.log', 'a'); + #$time_start = microtime(true); $databaseService = DatabaseService::getInstance(); $this->Database = $databaseService->GetDbConnection(); - fwrite($fp, "%%% Login controller - parent construstor database time : " . round((microtime(true) - $time_start),6) . "\n"); + #fwrite($fp, "%%% Login controller - parent construstor database time : " . round((microtime(true) - $time_start),6) . "\n"); $localizationService = LocalizationService::getInstance(GROCY_CULTURE); $this->LocalizationService = $localizationService; - fwrite($fp, "%%% Login controller - parent construstor localisation time : " . round((microtime(true) - $time_start),6) . "\n"); + #fwrite($fp, "%%% Login controller - parent construstor localisation time : " . round((microtime(true) - $time_start),6) . "\n"); $applicationService = ApplicationService::getInstance(); $versionInfo = $applicationService->GetInstalledVersion(); $container->view->set('version', $versionInfo->Version); $container->view->set('releaseDate', $versionInfo->ReleaseDate); - fwrite($fp, "%%% Login controller - parent construstor application service time : " . round((microtime(true) - $time_start),6) . "\n"); + #fwrite($fp, "%%% Login controller - parent construstor application service time : " . round((microtime(true) - $time_start),6) . "\n"); $container->view->set('__t', function(string $text, ...$placeholderValues) use($localizationService) { @@ -59,7 +59,7 @@ class BaseController $container->view->set('featureFlags', $constants); $container->view->set('userentitiesForSidebar', $this->Database->userentities()->where('show_in_sidebar_menu = 1')->orderBy('name')); - fwrite($fp, "%%% Login controller - parent construstor view time : " . round((microtime(true) - $time_start),6) . "\n"); + #fwrite($fp, "%%% Login controller - parent construstor view time : " . round((microtime(true) - $time_start),6) . "\n"); try { @@ -79,8 +79,8 @@ class BaseController } $this->AppContainer = $container; - fwrite($fp, "%%% Login controller - parent construstor total time : " . round((microtime(true) - $time_start),6) . "\n"); - fclose($fp); + #fwrite($fp, "%%% Login controller - parent construstor total time : " . round((microtime(true) - $time_start),6) . "\n"); + #fclose($fp); } protected $AppContainer; diff --git a/controllers/LoginController.php b/controllers/LoginController.php index 923546ad..e841bb36 100644 --- a/controllers/LoginController.php +++ b/controllers/LoginController.php @@ -10,15 +10,15 @@ class LoginController extends BaseController { public function __construct(\Slim\Container $container, string $sessionCookieName) { - $fp = fopen('/config/data/sql.log', 'a'); - $time_start = microtime(true); + #$fp = fopen('/config/data/sql.log', 'a'); + #$time_start = microtime(true); parent::__construct($container); - fwrite($fp, "£££ Login controller - parent construstor time : " . round((microtime(true) - $time_start),6) . "\n"); + #fwrite($fp, "£££ Login controller - parent construstor time : " . round((microtime(true) - $time_start),6) . "\n"); #$this->SessionService = SessionService::getInstance(); #fwrite($fp, "£££ Login controller - got session service instance : " . round((microtime(true) - $time_start),6) . "\n"); $this->SessionCookieName = $sessionCookieName; - fwrite($fp, "£££ Login controller - construction time : " . round((microtime(true) - $time_start),6) . "\n"); - fclose($fp); + #fwrite($fp, "£££ Login controller - construction time : " . round((microtime(true) - $time_start),6) . "\n"); + #fclose($fp); } protected $SessionService = null; @@ -35,9 +35,9 @@ class LoginController extends BaseController public function ProcessLogin(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) { - $fp = fopen('/config/data/sql.log', 'a'); - fwrite($fp, "£££ Login controller - ProcessLogin called\n"); - fclose($fp); + #$fp = fopen('/config/data/sql.log', 'a'); + #fwrite($fp, "£££ Login controller - ProcessLogin called\n"); + #fclose($fp); $postParams = $request->getParsedBody(); if (isset($postParams['username']) && isset($postParams['password'])) { diff --git a/controllers/SystemApiController.php b/controllers/SystemApiController.php index ae7c5c32..2e61758d 100644 --- a/controllers/SystemApiController.php +++ b/controllers/SystemApiController.php @@ -19,15 +19,15 @@ class SystemApiController extends BaseApiController public function GetDbChangedTime(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) { - $fp = fopen('/config/data/sql.log', 'a'); - fwrite($fp, "---- getting db changed time ----\n"); - $time_start = microtime(true); + #$fp = fopen('/config/data/sql.log', 'a'); + #fwrite($fp, "---- getting db changed time ----\n"); + #$time_start = microtime(true); $response = $this->ApiResponse(array( 'changed_time' => $this->DatabaseService->GetDbChangedTime() )); - fwrite($fp, "----Total execution time in seconds: " . round((microtime(true) - $time_start),4) . "\n"); - fwrite($fp, "---- time obtained ----\n"); - fclose($fp); + #fwrite($fp, "----Total execution time in seconds: " . round((microtime(true) - $time_start),4) . "\n"); + #fwrite($fp, "---- time obtained ----\n"); + #fclose($fp); return $response; #return $this->ApiResponse(array( # 'changed_time' => $this->DatabaseService->GetDbChangedTime() diff --git a/middleware/SessionAuthMiddleware.php b/middleware/SessionAuthMiddleware.php index a03ec335..02a46679 100644 --- a/middleware/SessionAuthMiddleware.php +++ b/middleware/SessionAuthMiddleware.php @@ -9,20 +9,20 @@ class SessionAuthMiddleware extends BaseMiddleware { public function __construct(\Slim\Container $container, string $sessionCookieName) { - $fp = fopen('/config/data/sql.log', 'a'); - $time_start = microtime(true); + #$fp = fopen('/config/data/sql.log', 'a'); + #$time_start = microtime(true); parent::__construct($container); $this->SessionCookieName = $sessionCookieName; - fwrite($fp, "£££ SessionAuthMiddleware - construction time : " . round((microtime(true) - $time_start),6) . "\n"); - fclose($fp); + #fwrite($fp, "£££ SessionAuthMiddleware - construction time : " . round((microtime(true) - $time_start),6) . "\n"); + #fclose($fp); } protected $SessionCookieName; public function __invoke(\Slim\Http\Request $request, \Slim\Http\Response $response, callable $next) { - $fp = fopen('/config/data/sql.log', 'a'); - $time_start = microtime(true); + #$fp = fopen('/config/data/sql.log', 'a'); + #$time_start = microtime(true); $route = $request->getAttribute('route'); $routeName = $route->getName(); $sessionService = SessionService::getInstance(); @@ -63,8 +63,8 @@ class SessionAuthMiddleware extends BaseMiddleware $response = $next($request, $response); } } - fwrite($fp, "£££ SessionAuthMiddleware - invocation time : " . round((microtime(true) - $time_start),6) . "\n"); - fclose($fp); + #fwrite($fp, "£££ SessionAuthMiddleware - invocation time : " . round((microtime(true) - $time_start),6) . "\n"); + #fclose($fp); return $response; } diff --git a/routes.php b/routes.php index 6d6324b7..82611758 100644 --- a/routes.php +++ b/routes.php @@ -1,26 +1,26 @@ LoginControllerInstance->GetSessionCookieName(); -fwrite($fp, "*** routing - session cookie name time : " . $session_cookie_name . "\n"); -fwrite($fp, "*** routing - get session cookie name time : " . round((microtime(true) - $main_route_time_start),6) . "\n"); +#fwrite($fp, "*** routing - session cookie name time : " . $session_cookie_name . "\n"); +#fwrite($fp, "*** routing - get session cookie name time : " . round((microtime(true) - $main_route_time_start),6) . "\n"); $session_auth_middelware = new SessionAuthMiddleware($appContainer, $session_cookie_name); -fwrite($fp, "*** routing - create session auth middleware time : " . round((microtime(true) - $main_route_time_start),6) . "\n"); +#fwrite($fp, "*** routing - create session auth middleware time : " . round((microtime(true) - $main_route_time_start),6) . "\n"); $app->group('', function() { - $fp = fopen('/config/data/sql.log', 'a'); - $time_start = microtime(true); + #$fp = fopen('/config/data/sql.log', 'a'); + #$time_start = microtime(true); // System routes $this->get('/', '\Grocy\Controllers\SystemController:Root')->setName('root'); @@ -44,8 +44,8 @@ $app->group('', function() $this->get('/users', '\Grocy\Controllers\UsersController:UsersList'); $this->get('/user/{userId}', '\Grocy\Controllers\UsersController:UserEditForm'); - fwrite($fp, "*** routing - main route add base routes load time : " . round((microtime(true) - $time_start),6) . "\n"); - $stock_time_start = microtime(true); + #fwrite($fp, "*** routing - main route add base routes load time : " . round((microtime(true) - $time_start),6) . "\n"); + #$stock_time_start = microtime(true); // Stock routes if (GROCY_FEATURE_FLAG_STOCK) @@ -68,8 +68,8 @@ $app->group('', function() $this->get('/locationcontentsheet', '\Grocy\Controllers\StockController:LocationContentSheet'); $this->get('/quantityunitpluraltesting', '\Grocy\Controllers\StockController:QuantityUnitPluralFormTesting'); } - fwrite($fp, "*** routing - main route add stock routes load time : " . round((microtime(true) - $stock_time_start),6) . "\n"); - $shopping_time_start = microtime(true); + #fwrite($fp, "*** routing - main route add stock routes load time : " . round((microtime(true) - $stock_time_start),6) . "\n"); + #$shopping_time_start = microtime(true); // Shopping list routes if (GROCY_FEATURE_FLAG_SHOPPINGLIST) @@ -78,8 +78,8 @@ $app->group('', function() $this->get('/shoppinglistitem/{itemId}', '\Grocy\Controllers\StockController:ShoppingListItemEditForm'); $this->get('/shoppinglist/{listId}', '\Grocy\Controllers\StockController:ShoppingListEditForm'); } - fwrite($fp, "*** routing - main route add shopping routes load time : " . round((microtime(true) - $shopping_time_start),6) . "\n"); - $recipies_time_start = microtime(true); + #fwrite($fp, "*** routing - main route add shopping routes load time : " . round((microtime(true) - $shopping_time_start),6) . "\n"); + #$recipies_time_start = microtime(true); // Recipe routes if (GROCY_FEATURE_FLAG_RECIPES) @@ -89,8 +89,8 @@ $app->group('', function() $this->get('/recipe/{recipeId}/pos/{recipePosId}', '\Grocy\Controllers\RecipesController:RecipePosEditForm'); $this->get('/mealplan', '\Grocy\Controllers\RecipesController:MealPlan'); } - fwrite($fp, "*** routing - main route add recipies routes load time : " . round((microtime(true) - $recipies_time_start),6) . "\n"); - $chores_time_start = microtime(true); + #fwrite($fp, "*** routing - main route add recipies routes load time : " . round((microtime(true) - $recipies_time_start),6) . "\n"); + #$chores_time_start = microtime(true); // Chore routes if (GROCY_FEATURE_FLAG_CHORES) @@ -102,8 +102,8 @@ $app->group('', function() $this->get('/chore/{choreId}', '\Grocy\Controllers\ChoresController:ChoreEditForm'); $this->get('/choressettings', '\Grocy\Controllers\ChoresController:ChoresSettings'); } - fwrite($fp, "*** routing - main route add chores routes load time : " . round((microtime(true) - $chores_time_start),6) . "\n"); - $batteries_time_start = microtime(true); + #fwrite($fp, "*** routing - main route add chores routes load time : " . round((microtime(true) - $chores_time_start),6) . "\n"); + #$batteries_time_start = microtime(true); // Battery routes if (GROCY_FEATURE_FLAG_BATTERIES) @@ -115,8 +115,8 @@ $app->group('', function() $this->get('/battery/{batteryId}', '\Grocy\Controllers\BatteriesController:BatteryEditForm'); $this->get('/batteriessettings', '\Grocy\Controllers\BatteriesController:BatteriesSettings'); } - fwrite($fp, "*** routing - main route add batteries routes load time : " . round((microtime(true) - $batteries_time_start),6) . "\n"); - $tasks_time_start = microtime(true); + #fwrite($fp, "*** routing - main route add batteries routes load time : " . round((microtime(true) - $batteries_time_start),6) . "\n"); + #$tasks_time_start = microtime(true); // Task routes if (GROCY_FEATURE_FLAG_TASKS) @@ -127,8 +127,8 @@ $app->group('', function() $this->get('/taskcategory/{categoryId}', '\Grocy\Controllers\TasksController:TaskCategoryEditForm'); $this->get('/taskssettings', '\Grocy\Controllers\TasksController:TasksSettings'); } - fwrite($fp, "*** routing - main route add tasks routes load time : " . round((microtime(true) - $tasks_time_start),6) . "\n"); - $equipment_time_start = microtime(true); + #fwrite($fp, "*** routing - main route add tasks routes load time : " . round((microtime(true) - $tasks_time_start),6) . "\n"); + #$equipment_time_start = microtime(true); // Equipment routes if (GROCY_FEATURE_FLAG_EQUIPMENT) @@ -136,29 +136,29 @@ $app->group('', function() $this->get('/equipment', '\Grocy\Controllers\EquipmentController:Overview'); $this->get('/equipment/{equipmentId}', '\Grocy\Controllers\EquipmentController:EditForm'); } - fwrite($fp, "*** routing - main route add equipment routes load time : " . round((microtime(true) - $equipment_time_start),6) . "\n"); - $calendar_time_start = microtime(true); + #fwrite($fp, "*** routing - main route add equipment routes load time : " . round((microtime(true) - $equipment_time_start),6) . "\n"); + #$calendar_time_start = microtime(true); // Calendar routes if (GROCY_FEATURE_FLAG_CALENDAR) { $this->get('/calendar', '\Grocy\Controllers\CalendarController:Overview'); } - fwrite($fp, "*** routing - main route add calendar routes load time : " . round((microtime(true) - $calendar_time_start),6) . "\n"); - $openapi_time_start = microtime(true); + #fwrite($fp, "*** routing - main route add calendar routes load time : " . round((microtime(true) - $calendar_time_start),6) . "\n"); + #$openapi_time_start = microtime(true); // OpenAPI routes $this->get('/api', '\Grocy\Controllers\OpenApiController:DocumentationUi'); $this->get('/manageapikeys', '\Grocy\Controllers\OpenApiController:ApiKeysList'); $this->get('/manageapikeys/new', '\Grocy\Controllers\OpenApiController:CreateNewApiKey'); - fwrite($fp, "*** routing - main route add open api routes load time : " . round((microtime(true) - $openapi_time_start),6) . "\n"); - fwrite($fp, "*** routing - main route add all routes load time : " . round((microtime(true) - $time_start),6) . "\n"); - fclose($fp); + #fwrite($fp, "*** routing - main route add open api routes load time : " . round((microtime(true) - $openapi_time_start),6) . "\n"); + #fwrite($fp, "*** routing - main route add all routes load time : " . round((microtime(true) - $time_start),6) . "\n"); + #fclose($fp); })->add($session_auth_middelware); -fwrite($fp, "*** routing - main route load time : " . round((microtime(true) - $main_route_time_start),6) . "\n"); -$api_route_time_start = microtime(true); +#fwrite($fp, "*** routing - main route load time : " . round((microtime(true) - $main_route_time_start),6) . "\n"); +#$api_route_time_start = microtime(true); $app->group('/api', function() { @@ -278,7 +278,7 @@ $app->group('/api', function() 'credentials' => false, 'cache' => 0, ])); -fwrite($fp, "*** routing - api route load time : " . round((microtime(true) - $api_route_time_start),6) . "\n"); +#fwrite($fp, "*** routing - api route load time : " . round((microtime(true) - $api_route_time_start),6) . "\n"); -fwrite($fp, "*** routing - total load time : " . round((microtime(true) - $route_time_start),6) . "\n"); -fclose($fp); +#fwrite($fp, "*** routing - total load time : " . round((microtime(true) - $route_time_start),6) . "\n"); +#fclose($fp);