Exemplo n.º 1
0
 public function log($loggingLevel = 2)
 {
     if (is_writable($this->logFile)) {
         $message = 'Log info: ';
         if (!empty($this->postback)) {
             $message = $this->message . "\n" . "Postback info: " . serialize($this->postback) . "\n";
         }
         $message .= "\n";
         $hzl = new \Hubzero\Log\Writer(new \Monolog\Logger(Config::get('application_env')), Event::getRoot());
         $hzl->useFiles($this->logFile);
         if ($loggingLevel == 0) {
             $hzl->error($this->caller . ': ' . $message);
         } elseif ($loggingLevel == 1) {
             $log = $hzl->warning($this->caller . ': ' . $message);
             return $log;
         } elseif ($loggingLevel == 2) {
             $log = $hzl->info($this->caller . ': ' . $message);
             return $log;
         }
         // If error, needs to send email to admin
         $this->emailError($this->message, 'POSTBACK');
     } else {
         $this->emailError($this->logFile, 'LOG');
     }
 }
Exemplo n.º 2
0
 public function log($loggingLevel = 2)
 {
     if (!file_exists($this->logFile)) {
         try {
             Filesystem::write($this->logFile, '');
         } catch (\Exception $e) {
             $this->emailError($this->logFile, 'NO_LOG');
         }
     }
     if (is_writable($this->logFile)) {
         $message = 'Log info: ';
         $message .= $this->message;
         if (!empty($this->postback)) {
             $message .= "\n" . "Postback info: " . serialize($this->postback) . "\n";
         }
         $message .= "\n";
         $hzl = new \Hubzero\Log\Writer(new \Monolog\Logger(Config::get('application_env')), \JDispatcher::getInstance());
         $hzl->useFiles($this->logFile);
         if ($loggingLevel == 0) {
             $hzl->error($this->caller . ': ' . $message);
         } elseif ($loggingLevel == 1) {
             $log = $hzl->warning($this->caller . ': ' . $message);
             return $log;
         } elseif ($loggingLevel == 2) {
             $log = $hzl->info($this->caller . ': ' . $message);
             return $log;
         }
         // If error, needs to send email to admin
         $this->emailError($this->message, 'POSTBACK');
     } else {
         $this->emailError($this->logFile, 'LOG');
     }
 }