Example #1
0
 /**
  * Tests ALERT logging with alert()
  *
  * @author Nikos Dimopoulos <*****@*****.**>
  * @since  2012-09-17
  */
 public function testAlertLogging()
 {
     $fileName = $this->getFileName('log', 'log');
     $logger = new PhLoggerAdapterFile($this->logPath . $fileName);
     $logger->alert('Hello');
     $logger->close();
     $contents = file($this->logPath . $fileName);
     $found = strpos($contents[0], '[ALERT]');
     $this->assertTrue($found !== FALSE, 'Alert logging is not set to ALERT');
     $found = strpos($contents[0], 'Hello');
     $this->assertTrue($found !== FALSE, 'Alert logging does not set correct message');
     $this->cleanFile($this->logPath, $fileName);
 }
Example #2
0
<?php

use Phalcon\Logger\Adapter\File as FileAdapter;
// Create the logger
$logger = new FileAdapter("app/logs/test.log");
// Start a transaction
$logger->begin();
// Add messages
$logger->alert("This is an alert");
$logger->error("This is another error");
// Commit messages to file
$logger->commit();