@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | $streamHandler = new Monolog\Handler\StreamHandler(__DIR__ . '/../../logs/site.log', Monolog\Logger::INFO); |
| 11 | 11 | $streamHandler->setFormatter( |
| 12 | - new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message%\n") |
|
| 12 | + new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message%\n") |
|
| 13 | 13 | ); |
| 14 | 14 | $logger->pushHandler($streamHandler); |
| 15 | 15 | |
@@ -30,21 +30,21 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | // shutdown - note, this should be in a shutdown function |
| 32 | 32 | if ($_COOKIE['debugger'] == 'display') { |
| 33 | - $dbProfiles = $container['db_connection_locator'] |
|
| 34 | - ->getRead() |
|
| 35 | - ->getProfiler() |
|
| 36 | - ->getProfiles(); |
|
| 37 | - $dbProfiles = array_filter($dbProfiles, function ($profile) { |
|
| 38 | - return $profile['function'] == 'perform'; |
|
| 39 | - }); |
|
| 40 | - $dbProfiles = array_map(function ($profile) { |
|
| 41 | - return [ |
|
| 42 | - 'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])), |
|
| 43 | - 'parameters' => $profile['bind_values'], |
|
| 44 | - 'time' => $profile['duration'], |
|
| 45 | - ]; |
|
| 46 | - }, $dbProfiles); |
|
| 47 | - $container['profiler']->setProfiledQueries($dbProfiles); |
|
| 48 | - $container['profiler']->setDisplay(new Particletree\Pqp\Display()); |
|
| 49 | - $container['profiler']->display($container['db_connection_locator']->getRead()); |
|
| 33 | + $dbProfiles = $container['db_connection_locator'] |
|
| 34 | + ->getRead() |
|
| 35 | + ->getProfiler() |
|
| 36 | + ->getProfiles(); |
|
| 37 | + $dbProfiles = array_filter($dbProfiles, function ($profile) { |
|
| 38 | + return $profile['function'] == 'perform'; |
|
| 39 | + }); |
|
| 40 | + $dbProfiles = array_map(function ($profile) { |
|
| 41 | + return [ |
|
| 42 | + 'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])), |
|
| 43 | + 'parameters' => $profile['bind_values'], |
|
| 44 | + 'time' => $profile['duration'], |
|
| 45 | + ]; |
|
| 46 | + }, $dbProfiles); |
|
| 47 | + $container['profiler']->setProfiledQueries($dbProfiles); |
|
| 48 | + $container['profiler']->setDisplay(new Particletree\Pqp\Display()); |
|
| 49 | + $container['profiler']->display($container['db_connection_locator']->getRead()); |
|
| 50 | 50 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | $handle = @fopen($config_path, 'r'); |
| 9 | 9 | if ($handle === false) { |
| 10 | - throw new RuntimeException("Could not load config"); |
|
| 10 | + throw new RuntimeException("Could not load config"); |
|
| 11 | 11 | } |
| 12 | 12 | $config = fread($handle, filesize($config_path)); |
| 13 | 13 | fclose($handle); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | $config = json_decode($config); |
| 16 | 16 | $last_json_error = json_last_error(); |
| 17 | 17 | if ($last_json_error !== JSON_ERROR_NONE) { |
| 18 | - throw new RuntimeException("Could not parse config - JSON error detected"); |
|
| 18 | + throw new RuntimeException("Could not parse config - JSON error detected"); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | // timezones are fun |
@@ -24,34 +24,34 @@ discard block |
||
| 24 | 24 | // configure the db connections holder |
| 25 | 25 | $db_connections = new Aura\Sql\ConnectionLocator(); |
| 26 | 26 | $db_connections->setDefault(function () use ($config) { |
| 27 | - $connection = $config->database->slave; |
|
| 28 | - return new Aura\Sql\ExtendedPdo( |
|
| 29 | - "mysql:host={$connection->host}", |
|
| 30 | - $connection->user, |
|
| 31 | - $connection->password |
|
| 32 | - ); |
|
| 27 | + $connection = $config->database->slave; |
|
| 28 | + return new Aura\Sql\ExtendedPdo( |
|
| 29 | + "mysql:host={$connection->host}", |
|
| 30 | + $connection->user, |
|
| 31 | + $connection->password |
|
| 32 | + ); |
|
| 33 | 33 | }); |
| 34 | 34 | $db_connections->setWrite('master', function () use ($config) { |
| 35 | - $connection = $config->database->master; |
|
| 36 | - return new Aura\Sql\ExtendedPdo( |
|
| 37 | - "mysql:host={$connection->host}", |
|
| 38 | - $connection->user, |
|
| 39 | - $connection->password |
|
| 40 | - ); |
|
| 35 | + $connection = $config->database->master; |
|
| 36 | + return new Aura\Sql\ExtendedPdo( |
|
| 37 | + "mysql:host={$connection->host}", |
|
| 38 | + $connection->user, |
|
| 39 | + $connection->password |
|
| 40 | + ); |
|
| 41 | 41 | }); |
| 42 | 42 | $db_connections->setRead('slave', function () use ($config) { |
| 43 | - $connection = $config->database->slave; |
|
| 44 | - $pdo = new Aura\Sql\ExtendedPdo( |
|
| 45 | - "mysql:host={$connection->host}", |
|
| 46 | - $connection->user, |
|
| 47 | - $connection->password |
|
| 48 | - ); |
|
| 43 | + $connection = $config->database->slave; |
|
| 44 | + $pdo = new Aura\Sql\ExtendedPdo( |
|
| 45 | + "mysql:host={$connection->host}", |
|
| 46 | + $connection->user, |
|
| 47 | + $connection->password |
|
| 48 | + ); |
|
| 49 | 49 | |
| 50 | - $profiler = new Aura\Sql\Profiler(); |
|
| 51 | - $profiler->setActive(true); |
|
| 52 | - $pdo->setProfiler($profiler); |
|
| 50 | + $profiler = new Aura\Sql\Profiler(); |
|
| 51 | + $profiler->setActive(true); |
|
| 52 | + $pdo->setProfiler($profiler); |
|
| 53 | 53 | |
| 54 | - return $pdo; |
|
| 54 | + return $pdo; |
|
| 55 | 55 | }); |
| 56 | 56 | |
| 57 | 57 | // setup the profiler |