alert() public method

Method to add an ALERT log entry
public alert ( mixed $message, array $options = [] ) : Logger
$message mixed
$options array
return Logger
Beispiel #1
0
 public function testAlert()
 {
     $l = new Logger(new File(__DIR__ . '/../tmp/app.log'));
     $l->alert('Test log message');
     $this->assertTrue(file_exists(__DIR__ . '/../tmp/app.log'));
     $this->assertGreaterThan(0, filesize(__DIR__ . '/../tmp/app.log'));
     unlink(__DIR__ . '/../tmp/app.log');
 }
 /**
  * Log session
  *
  * @param  mixed   $config
  * @param  mixed   $user
  * @param  boolean $success
  * @return void
  */
 public static function log($config, $user, $success)
 {
     if ($config->log_type == 3 || $config->log_type == 2 && $success || $config->log_type == 1 && !$success) {
         $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
         $noreply = 'noreply@' . $domain;
         $options = ['subject' => ($success ? 'Successful' : 'Failed') . ' Login (' . $domain . ') : Phire CMS Session Notification', 'headers' => ['From' => $noreply . ' <' . $noreply . '>', 'Reply-To' => $noreply . ' <' . $noreply . '>']];
         $message = $success ? 'Someone has logged in at ' . $_SERVER['REQUEST_URI'] . ' as \'' . $user->username . '\' from ' . $_SERVER['REMOTE_ADDR'] : 'Someone attempted to log in at ' . $_SERVER['REQUEST_URI'] . ' as \'' . $user->username . '\' from ' . $_SERVER['REMOTE_ADDR'];
         $emails = explode(',', $config->log_emails);
         if (count($emails) > 0) {
             $logger = new Log\Logger(new Log\Writer\Mail($emails, $options));
             $logger->alert($message);
         }
     }
 }