OSDN Git Service

fixed: logwriter debugtoolbar ran on the cli context
authorSotaro KARASAWA <sotarok@users.sourceforge.jp>
Sun, 27 Mar 2011 11:17:13 +0000 (20:17 +0900)
committerSotaro KARASAWA <sotarok@users.sourceforge.jp>
Sun, 27 Mar 2011 11:17:13 +0000 (20:17 +0900)
extlib/Plugin/Logwriter/Debugtoolbar.php

index 2472524..df748a1 100644 (file)
@@ -81,10 +81,12 @@ class Ethna_Plugin_Logwriter_Debugtoolbar extends Ethna_Plugin_Logwriter
     function end()
     {
         $ctl = Ethna_Controller::getInstance();
-        if (!is_null($view = $ctl->getView()) && !$view->has_default_header) {
+        if ((!is_null($view = $ctl->getView()) && !$view->has_default_header)
+            || $ctl->getGateway() != GATEWAY_WWW) {
             $this->log_array = array();
             return null;
         }
+
         echo '<div class="ethna-debug" id="ethna-debug-logwindow">';
         echo '<div class="ethna-debug-title">Log</div>';
         foreach ($this->log_array as $log) {
@@ -98,6 +100,13 @@ class Ethna_Plugin_Logwriter_Debugtoolbar extends Ethna_Plugin_Logwriter
     public function __destruct()
     {
         if (!empty($this->log_array)) {
+            $ctl = Ethna_Controller::getInstance();
+            if ((!is_null($view = $ctl->getView()) && !$view->has_default_header)
+                || $ctl->getGateway() != GATEWAY_WWW) {
+                $this->log_array = array();
+                return null;
+            }
+
             echo "<h1>Script shutdown unexpectedly</h1>";
             if (is_array($this->log_array)) foreach ($this->log_array as $log) {
                 echo $log;