Monolog\Logger::addAlert PHP Method

addAlert() public method

Adds a log record at the ALERT level.
public addAlert ( string $message, array $context = [] ) : boolean
$message string The log message
$context array The log context
return boolean Whether the record has been processed
    public function addAlert($message, array $context = array())
    {
        return $this->addRecord(self::ALERT, $message, $context);
    }

Usage Example

Exemplo n.º 1
1
 /**
  * Create a new connection to the database
  *
  * @param string $host     The MySQL host
  * @param string $user     The MySQL user
  * @param string $password The MySQL password for the user
  * @param string $dbName   The MySQL database name
  *
  * @return Database A database object to interact with the database
  */
 public function __construct($host, $user, $password, $dbName)
 {
     if (Service::getContainer()) {
         if ($logger = Service::getContainer()->get('monolog.logger.mysql')) {
             $this->logger = $logger;
         }
     }
     $this->dbc = new mysqli($host, $user, $password, $dbName);
     if ($this->dbc->connect_errno) {
         $this->logger->addAlert($this->dbc->connect_error);
         throw new Exception($this->dbc->connect_error, $this->dbc->connect_errno);
     }
     $this->dbc->set_charset("utf8");
 }
All Usage Examples Of Monolog\Logger::addAlert