Alex Trofimov 6 лет назад
Родитель
Сommit
b00962b36e
2 измененных файлов с 30 добавлено и 6 удалено
  1. 22 3
      inc/classes/BxDolLogs.php
  2. 8 3
      samples/log.php

+ 22 - 3
inc/classes/BxDolLogs.php

@@ -112,11 +112,30 @@ class BxDolLogs extends BxDolFactory implements iBxDolFactoryObject
     /**
      * Get logs from current logs storage
      * @param $iLines number of lines from the tail to return
-     * @return array of strings
+     * @param $sFilter filter lines by keyword
+     * @return array of strings or false on error
      */
-    public function get($iLines = 30)
+    public function get($iLines = 30, $sFilter = '')
     {
-        return $this->_oLogsStorage->add($this, $mixed);
+        if (!$this->_oLogsStorage->isGetAvail())
+            return false;
+        return $this->_oLogsStorage->get($this, $iLines, $sFilter);
+    }
+
+    /**
+     * Check if filtering supported in `get` method
+     */
+    public function isFilterAvail()
+    {
+        return $this->_oLogsStorage->isFilterAvail();
+    }
+
+    /**
+     * Check if `get` method available
+     */
+    public function isGetAvail()
+    {
+        return $this->_oLogsStorage->isGetAvail();
     }
 }
 

+ 8 - 3
samples/log.php

@@ -31,12 +31,17 @@ function PageCompMainCode()
     ob_start();
 
     $ret = null;
-    // if ($o = BxDolLogs::getObjectInstance('sys_db_err'))
-    //    $ret = $o->add('Hello world!');
-    $ret = bx_log('sys_db_err', 'Hello world3!');
+    if ($o = BxDolLogs::getObjectInstance('sys_db_err'))
+        $ret = $o->add('Hello world!');
+    // $ret = bx_log('sys_db_err', 'Hello world!');
 
     var_dump($ret);
 
+    if ($o->isGetAvail())
+        echoDbg($o->get(30, 'world3'));
+    else
+        echo 'get logs n/a';
+
     return DesignBoxContent("Logs", ob_get_clean(), BX_DB_PADDING_DEF);
 }