@@ -190,7 +190,7 @@ private static function compressImage(string $path, int $quality = 85): string
190190 public static function getAssetCacheKey (string $ path ): string
191191 {
192192 $ encoding = CompressionBuffer::getFirstMethodChoice ();
193- if (compressTextAssets && self ::isCompressableTextAsset ($ path )) {
193+ if (COMPRESS_TEXT_ASSETS && self ::isCompressableTextAsset ($ path )) {
194194 return Cache::createCacheKeyFile ($ path , "assetCompression- $ encoding " );
195195 }
196196 return Cache::createCacheKeyFile ($ path , 'asset ' );
@@ -206,7 +206,7 @@ public static function doAssetCompression(string $path): array
206206 $ cacheKey = self ::getAssetCacheKey ($ path );
207207 $ encoding = 'identity ' ;
208208
209- if (compressTextAssets && self ::isCompressableTextAsset ($ path )) {
209+ if (COMPRESS_TEXT_ASSETS && self ::isCompressableTextAsset ($ path )) {
210210 CompressionBuffer::enable (); // We will use CompressionBuffer to handle text content
211211 $ encoding = CompressionBuffer::getFirstMethodChoice ();
212212
@@ -217,7 +217,7 @@ public static function doAssetCompression(string $path): array
217217 });
218218 }
219219
220- if (compressImageAssets && self ::isCompressableImage ($ path )) {
220+ if (COMPRESS_IMAGES && self ::isCompressableImage ($ path )) {
221221 $ contents = $ cache ->get ($ cacheKey , function (ItemInterface $ item ) use ($ path ): string {
222222 $ item ->expiresAfter (604800 );
223223 return self ::compressImage ($ path );
@@ -245,6 +245,10 @@ private static function createDebugLogLine(string $wording, bool|string $value):
245245
246246 public static function buildDebugInfo (): string
247247 {
248+ if (DEBUG_LEVEL === 0 ) {
249+ return '' ;
250+ }
251+
248252 $ elapsed_time = round ((hrtime (true ) - START ) / 1e+6 , 2 );
249253 $ mem_usage = round (memory_get_peak_usage () / 1e+6 , 2 );
250254
@@ -253,21 +257,23 @@ public static function buildDebugInfo(): string
253257 $ result .= self ::createDebugLogLine ('Time to process request ' , "$ elapsed_time ms " );
254258 $ result .= self ::createDebugLogLine ('Memory usage ' , "$ mem_usage MB " );
255259
256- // System info
257- $ result .= "<dt>System Info</dt> " ;
258- $ result .= self ::createDebugLogLine ('Output compression ' , doOutputCompression);
259-
260- if (CompressionBuffer::isEnabled () && doOutputCompression) {
261- $ method = CompressionBuffer::getFirstMethodChoice ();
262- if ($ method === 'br ' ) {
263- $ method = 'brotli ' ;
260+ if (DEBUG_LEVEL >= 2 ) {
261+ // System info
262+ $ result .= "<dt>System Info</dt> " ;
263+ $ result .= self ::createDebugLogLine ('Output compression ' , COMPRESS_OUTPUT );
264+
265+ if (CompressionBuffer::isEnabled () && COMPRESS_OUTPUT ) {
266+ $ method = CompressionBuffer::getFirstMethodChoice ();
267+ if ($ method === 'br ' ) {
268+ $ method = 'brotli ' ;
269+ }
270+ $ result .= self ::createDebugLogLine ('This page was compressed with ' , $ method );
264271 }
265- $ result .= self ::createDebugLogLine ('This page was compressed with ' , $ method );
266- }
267272
268- $ result .= self ::createDebugLogLine ('Asset compression ' , compressTextAssets);
269- $ result .= self ::createDebugLogLine ('Image compression ' , compressImageAssets);
270- $ result .= self ::createDebugLogLine ('PHP version ' , PHP_VERSION );
273+ $ result .= self ::createDebugLogLine ('Asset compression ' , COMPRESS_TEXT_ASSETS );
274+ $ result .= self ::createDebugLogLine ('Image compression ' , COMPRESS_IMAGES );
275+ $ result .= self ::createDebugLogLine ('PHP version ' , PHP_VERSION );
276+ }
271277
272278 return $ result . "</dl> " ;
273279 }
0 commit comments