Beispiel #1
0
function gravalog($numero, $texto, $pagina = null, $linha = null, $contexto = null)
{
    $ddf = fopen(DIR_LOGS . "/" . date('Y.M.d') . ".log", 'a');
    if ($ddf) {
        $datalog = date('d.m.Y H:i:s');
        $txt = "::[" . $datalog . "]--|" . ip() . "|----------------------\n";
        $txt .= "(" . $numero . ") " . $texto . "\n";
        if (!is_null($pagina)) {
            $txt .= "Pagina: " . $pagina . "\n";
        }
        if (!is_null($linha)) {
            $txt .= "Linha: " . $linha . "\n";
        }
        $txt .= "\n";
        if (PROFILER) {
            if (class_exists("Console")) {
                $e = new ErrorException($texto, 0, $numero, $pagina, $linha);
                Console::logError($e, $texto);
            }
        }
        if (fwrite($ddf, $txt)) {
            return true;
            if (DEBUG) {
                alert('Arquivo gravado com sucesso', false);
            }
        }
    } else {
        if (DEBUG) {
            alert('Erro ao gravar arquivo', false);
        }
    }
    fclose($ddf);
}
Beispiel #2
0
	public function sampleConsoleData() {
		try {
			Console::log('Begin logging data');
			Console::logMemory($this, 'PQP Example Class : Line '.__LINE__);
			Console::logSpeed('Time taken to get to line '.__LINE__);
			Console::log(array('Name' => 'Ryan', 'Last' => 'Campbell'));
			Console::logSpeed('Time taken to get to line '.__LINE__);
			Console::logMemory($this, 'PQP Example Class : Line '.__LINE__);
			Console::log('Ending log below with a sample error.');
			throw new Exception('Unable to write to log!');
		}
		catch(Exception $e) {
			Console::logError($e, 'Sample error logging.');
		}
	}
 function wpdt_log_error($exception, $message)
 {
     Console::logError($exception, $message);
 }
Beispiel #4
0
 /**
  * Any logs sent in the GET request will be removed from the data property and added through the Console class.
  * The returned array will be all original key/value pairs minus logs
  *
  * @param array $data
  * @return array
  */
 private function setLogsFromData($data)
 {
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         foreach ($data as $key => $value) {
             if ($key == 'logs' && is_array($value)) {
                 foreach ($value as $key => $log) {
                     if (isset($log['type']) && isset($log['message']) && isset($log['file']) && isset($log['line'])) {
                         switch ($log['type']) {
                             case Console::ALERT:
                                 Console::alert($log['message']);
                                 unset($data[$key]);
                                 break;
                             case Console::LOG:
                                 Console::log($log['message'], $log['file'], $log['line']);
                                 unset($data[$key]);
                                 break;
                             case Console::ERROR:
                                 Console::logError($log['message'], $log['file'], $log['line']);
                                 unset($data[$key]);
                                 break;
                             default:
                                 break;
                         }
                     }
                 }
             }
         }
     }
     return $data;
 }
Beispiel #5
0
 /**
  *
  */
 public function testLogErrorInsertedToDatabase()
 {
     $db = new Database();
     $get_logcount_stmt = $db->prepare('SELECT count(id) AS num_logs FROM Logs');
     $get_logcount_stmt->execute();
     $row = $db->getRow($get_logcount_stmt);
     Console::logError('test', 'file.php', '111');
     $logs = Console::getLogs();
     $this->assertEquals($row->num_logs + 1, $logs[0]['id']);
 }
Beispiel #6
0
 /**
  * Use this function to add javascript to the views
  *
  * Just pass the location from httpdocs/js/
  *
  * @param string $loc
  */
 protected final function addJS($loc)
 {
     if (file_exists($script = Walleye::getInstance()->getServerBaseDir() . 'httpdocs/js/' . $loc)) {
         $scripts = $this->values['js'];
         $scripts[] = $script;
         $this->values['js'] = $scripts;
     } else {
         Console::logError('Passed a javascript that cannot be found: ' . $loc);
     }
 }
 public static function error($exception)
 {
     if (isset(self::$profiler)) {
         Console::logError($exception);
     }
 }