From 587520ecb5a7e50e0a57a57e7845a458447d5b6d Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 16 Aug 2012 20:50:58 +0200 Subject: [PATCH] add logging --- surrogator.php | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/surrogator.php b/surrogator.php index e48190e..b9f724d 100644 --- a/surrogator.php +++ b/surrogator.php @@ -1,18 +1,36 @@ getPathname(); @@ -21,7 +39,9 @@ foreach ($dir as $fileInfo) { $squarePath = $varDir . '/square/' . substr($fileName, 0, -strlen($ext)) . 'png'; + log('processing ' . $fileName); if (image_uptodate($origPath, $squarePath)) { + log(' image up to date'); continue; } @@ -29,8 +49,15 @@ foreach ($dir as $fileInfo) { continue; } - list($md5, $sha256) = getHashes($fileName); + if ($fileName == 'default.png') { + $md5 = $sha256 = 'default'; + } else { + list($md5, $sha256) = getHashes($fileName); + } + log(' Creating sizes for ' . $fileName); + log(' md5: ' . $md5); + log(' sha256: ' . $sha256); $imgSquare = imagecreatefrompng($squarePath); foreach ($sizes as $size) { $sizePathMd5 = $varDir . '/' . $size . '/' . $md5 . '.png'; @@ -80,10 +107,7 @@ function createSquare($origPath, $ext, $targetPath, $maxSize) } if ($imgOrig === false) { - file_put_contents( - 'php://stderr', - 'Error loading image file: ' . $origPath - ); + logErr('Error loading image file: ' . $origPath); return false; } @@ -135,4 +159,14 @@ function image_uptodate($sourcePath, $targetPath) return true; } +function log($msg) +{ + echo $msg . "\n"; +} + +function logErr($msg) +{ + file_put_contents('php://stderr', $msg . "\n"); +} + ?> -- 2.30.2