<?php require 'vendor/autoload.php'; /* Exemple de fichier utilisant les logs */ $users = [['name' => 'Kenny Katzgrau', 'username' => 'katzgrau'], ['name' => 'Dan Horrigan', 'username' => 'dhrrgn']]; $logger = new Katzgrau\KLogger\Logger(__DIR__ . '/logs'); $logger->info('Returned a million search results'); $logger->error('Oh dear.'); $logger->debug('Got these users from the Database.', $users);
date_default_timezone_set('UTC'); require 'vendor/autoload.php'; require __DIR__ . '/common.php'; $logger = new Katzgrau\KLogger\Logger(__DIR__ . '/logs/test', Psr\Log\LogLevel::DEBUG); /** * Test that we have proper access to * * - Git Hub * - SQS * - S3 */ try { $config = new \Io\Samk\AmiBuilder\Utils\Config(__DIR__ . "/config/config.yml"); } catch (\Exception $e) { $logger->error("There was a problem loading the config. Error: '{$e->getMessage()}'"); shutDown("Problem Loading Config File. Error: '{$e->getMessage()}'"); } $awsConfig = $config->get('awsConfig', true); $sqsConfig = $config->get('sqsConfig', true); /** * Init AWS SDK */ $aws = \Aws\Common\Aws::factory($awsConfig); /** * Test SQS connectivity */ /** @var \Aws\Sqs\SqsClient $sqsClient */ $sqsClient = $aws->get('sqs'); $queueUrl = $sqsConfig['amiBuildRequestQueueUrl']; try {
$accessToken = "mcWxFEgcVbIAAAAAAAACgctpLBLkmojYc8kXY4IJDgQvtBdKiPXaUBT5bRDoj9Mu"; $appInfo = dbx\AppInfo::loadFromJsonFile($includes . "vendor/dropbox-sdk/Dropbox/app-info.json"); $webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0"); $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0"); $accountInfo = $dbxClient->getAccountInfo(); */ $log->debug('Drobox Created'); /******************************************************************************************************************************* ******************************************************************************************************************************** Check Database Connetion ******************************************************************************************************************************** *******************************************************************************************************************************/ $log->debug('Testing SQL Connetion'); $db = new MysqliDb(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if ($db->getLastError() == null) { $log->error("Failed to connect to MySQL: " . $db->getLastError()); //failed(); exit; } $log->info('We have a good SQL Connetion'); /******************************************************************************************************************************* ******************************************************************************************************************************** CREATE CSV ******************************************************************************************************************************** *******************************************************************************************************************************/ $log->debug('Creating CSV'); //FULL CSV Path $CVSFilePath = $CSVFileLocation . $CSVfileName; //Delete old file CSV file $log->debug('Deleting old CSV File'); if (!unlink($CVSFilePath)) {
public function run($formula) { $tmp_name = tempnam(TMP_DIR, ''); $tex_source = $this->templater->run($formula); if ($this->is_debug) { echo '<pre>', htmlspecialchars($tex_source), '</pre>'; } // Latex file_put_contents($tmp_name, $tex_source); try { list($out, $status) = Lib::ExecWaitTimeout($this->latex_command . ' ' . $tmp_name . ' 2>&1'); if ($this->is_debug) { echo '<pre>'; readfile($tmp_name . '.log'); var_dump($status); echo '</pre>'; } } catch (Exception $e) { if ($this->log_dir !== null) { $logger = new Katzgrau\KLogger\Logger($this->log_dir); $logger->error('Cannot run Latex', array($e->getMessage())); $logger->error('source', array($tex_source)); } throw $e; } $is_latex_error = !file_exists($tmp_name . '.dvi'); if (!file_exists($tmp_name . '.dvi') || isset($status['status_kill'])) { // Ohe has to figure out why the process was killed and why no dvi-file is created. if ($this->log_dir !== null) { $logger = new Katzgrau\KLogger\Logger($this->log_dir); $logger->error('Latex finished incorrectly'); $logger->error('status', $status + array("file_exists({$tmp_name}.dvi)" => file_exists($tmp_name . '.dvi'))); $logger->error('source', array($tex_source)); $logger->error('trace', array(file_get_contents($tmp_name . '.log'))); } } if ($is_latex_error) { if ($this->is_debug) { echo '<pre>'; var_dump($this); echo '</pre>'; } $this->cleanupTempFiles($tmp_name); throw new Exception('Invalid formula'); } // DVI -> SVG ob_start(); passthru(sprintf($this->svg_command, $tmp_name)); $svg = ob_get_clean(); // $svg = '...<!--start 19.8752 31.3399 -->...'; $is_start = preg_match('#<!--start ([\\d.]+) ([\\d.]+) -->#', $svg, $match_start); $is_bbox = preg_match('#<!--bbox ([\\d.]+) ([\\d.]+) ([\\d.]+) ([\\d.]+) -->#', $svg, $match_bbox); if ($is_start && $is_bbox) { // SVG contains info about image size and baseline position. $depth = round(OUTER_SCALE * (-$match_start[2] + $match_bbox[2] + $match_bbox[4]), self::SVG_PRECISION); $height = round(OUTER_SCALE * $match_bbox[4], self::SVG_PRECISION); $width = round(OUTER_SCALE * $match_bbox[3], self::SVG_PRECISION); // Embed script providing that info to parent. $script = '<script type="text/ecmascript">if(window.parent.postMessage)window.parent.postMessage("' . $depth . '|' . $width . '|' . $height . '|"+window.location,"*");</script>' . "\n"; $svg = str_replace('<defs>', $script . '<defs>', $svg); } $this->svg = $svg; // DVI -> PNG exec(sprintf($this->png_command, $tmp_name, $tmp_name)); $this->png = file_get_contents($tmp_name . '.png'); // Cleaning up $this->cleanupTempFiles($tmp_name); }