From: Christian Weiske Date: Thu, 16 Aug 2012 18:50:58 +0000 (+0200) Subject: add logging X-Git-Tag: v0.1.0~23 X-Git-Url: https://git.cweiske.de/surrogator.git/commitdiff_plain/587520ecb5a7e50e0a57a57e7845a458447d5b6d add logging --- 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"); +} + ?>