diff --git a/src/QUI/ERP/Shipping/Debug.php b/src/QUI/ERP/Shipping/Debug.php index 41ae82e01a96590934011ce9722717294e1f68da..4eb4d37b264c3fdef5e0a554c1955ccea49a3ccf 100644 --- a/src/QUI/ERP/Shipping/Debug.php +++ b/src/QUI/ERP/Shipping/Debug.php @@ -5,6 +5,8 @@ use QUI; use QUI\ERP\Shipping\Types\ShippingEntry; +use function class_exists; + /** * Class Debug */ @@ -131,7 +133,7 @@ public static function generateShippingEntryDebuggingLog( $debugMessage .= '⌠'; } - $debugMessage .= $entry['id'].' - '.$entry['title'].' -> '.$entry['reason']; + $debugMessage .= $entry['id'] . ' - ' . $entry['title'] . ' -> ' . $entry['reason']; } try { @@ -172,7 +174,11 @@ public static function getLogger() } $Logger = new \Monolog\Logger('quiqqer-shipping'); - $Logger->pushHandler(new \Monolog\Handler\BrowserConsoleHandler(\Monolog\Logger::DEBUG)); + + if (class_exists('Monolog\Handler\BrowserConsoleHandler')) { + $Logger->pushHandler(new \Monolog\Handler\BrowserConsoleHandler(\Monolog\Logger::DEBUG)); + } + $Logger->pushHandler(new \Monolog\Handler\FirePHPHandler(\Monolog\Logger::DEBUG)); $Logger->pushHandler(new \Monolog\Handler\ChromePHPHandler(\Monolog\Logger::DEBUG)); @@ -190,8 +196,12 @@ public static function getLoggerWithoutFormatter() return self::$FormatLogger; } - $Logger = new \Monolog\Logger('quiqqer-shipping'); - $Console = new \Monolog\Handler\BrowserConsoleHandler(\Monolog\Logger::DEBUG); + $Logger = new \Monolog\Logger('quiqqer-shipping'); + + if (class_exists('Monolog\Handler\BrowserConsoleHandler')) { + $Console = new \Monolog\Handler\BrowserConsoleHandler(\Monolog\Logger::DEBUG); + } + $FireFox = new \Monolog\Handler\FirePHPHandler(\Monolog\Logger::DEBUG); $Chrome = new \Monolog\Handler\ChromePHPHandler(\Monolog\Logger::DEBUG); @@ -203,12 +213,15 @@ public static function getLoggerWithoutFormatter() true // ignoreEmptyContextAndExtra option, default false ); - $Console->setFormatter($Formatter); - $FireFox->setFormatter($Formatter); - $Chrome->setFormatter($Formatter); + if (isset($Console)) { + $Console->setFormatter($Formatter); + $Logger->pushHandler($Console); + } - $Logger->pushHandler($Console); + $FireFox->setFormatter($Formatter); $Logger->pushHandler($FireFox); + + $Chrome->setFormatter($Formatter); $Logger->pushHandler($Chrome); self::$FormatLogger = $Logger;