Ejemplo n.º 1
0
 private function __construct()
 {
     // setup file error logging
     $file_writer = new Logger_Errorlog();
     if (Config::get_optional("DEBUG_LOG") == false) {
         $file_writer->addFilter(Zend_Log::INFO);
     }
     $log = new Zend_Log();
     $log->addWriter($file_writer);
     // setup email error logging
     if (Config::get_optional("log_to_email") == true) {
         $mail = new Zend_Mail();
         $mail->setFrom(Config::get_mandatory('log_email_from'));
         $mail->addTo(Config::get_mandatory('log_email_to'));
         // setup email template
         $layout = new Zend_Layout();
         $layout->setLayoutPath(DOCUMENT_ROOT . Config::get_mandatory("log_email_template"));
         $layout->setLayout('error-logger');
         $layout_formatter = new Zend_Log_Formatter_Simple('<li>.' . Zend_Log_Formatter_Simple::DEFAULT_FORMAT . '</li>');
         // Use default HTML layout.
         $email_writer = new Zend_Log_Writer_Mail($mail, $layout);
         $email_writer->setLayoutFormatter($layout_formatter);
         $email_writer->setSubjectPrependText(Config::get_mandatory('log_email_subject_prepend'));
         $email_writer->addFilter(Zend_Log::ERR);
         $log->addWriter($email_writer);
     }
     self::$logger = $log;
 }
Ejemplo n.º 2
0
 public static function addLogger($logger, $reset = false)
 {
     if ($reset) {
         self::$logger = array();
     }
     self::$logger[] = $logger;
     self::$enabled = true;
 }
Ejemplo n.º 3
0
 public static function L($logpath = '', $clear = false)
 {
     if (self::$logger === null) {
         self::$logger = new Logger($logpath, $clear);
     }
     self::$logger->setClear($clear);
     return self::$logger;
 }
Ejemplo n.º 4
0
 public static function addLogger($logger, $reset = false)
 {
     if ($reset) {
         self::$logger = array();
     }
     self::$logger[] = $logger;
     self::$dummyMode = false;
 }
Ejemplo n.º 5
0
 static function __callStatic($name, $args)
 {
     if (!self::$logger) {
         self::$logger = new Monolog\Logger('debug');
         self::$logger->pushHandler(new Monolog\Handler\StreamHandler(__DIR__ . '/../log/debug.log'));
     }
     return call_user_func_array([self::$logger, $name], $args);
 }
Ejemplo n.º 6
0
 /**
  * @param $logger
  * @param bool|false $reset
  * @throws Exception
  */
 public static function addLogger($logger, $reset = false)
 {
     if (!$logger instanceof \Zend_Log && !$logger instanceof \Psr\Log\LoggerInterface) {
         throw new \Exception("Logger must be either an instance of Zend_Log or needs to implement Psr\\Log\\LoggerInterface");
     }
     if ($reset) {
         self::$logger = array();
     }
     self::$logger[] = $logger;
     self::$enabled = true;
 }
Ejemplo n.º 7
0
 /**
  * Retrieve the singleton logger instance, creating it if necessary.
  *
  * @return Returns the logger.
  */
 public static function getLogger()
 {
     // Make sure the logger has been created.
     if (self::$logger === null) {
         // Define the logging format.
         $format = '%timestamp% %priorityName% %message%' . PHP_EOL;
         // Create the formatter.
         $formatter = new Zend_Log_Formatter_Simple($format);
         // Create the new writer for the log file.
         $writer = new Zend_Log_Writer_Stream(Bootstrap::$root . '/logs/app.log');
         // Set the writer format.
         $writer->setFormatter($formatter);
         // Create the logger.
         self::$logger = new Zend_Log($writer);
     }
     // Return the logger.
     return self::$logger;
 }