Exemplo n.º 1
0
 /**
  * Will all a log record in go_log
  * Made protected to be used in \GO\Files\Model\File
  * @param string $action
  * @param boolean $save set the false to not directly save the create Log record
  * @return boolean|\GO\Log\Model\Log returns the created log or succuss status when save is true
  */
 protected function log($action, $save = true)
 {
     $message = $this->getLogMessage($action);
     if ($message && GO::modules()->isInstalled('log')) {
         $log = new \GO\Log\Model\Log();
         $pk = $this->pk;
         $log->model_id = is_array($pk) ? var_export($pk, true) : $pk;
         $log->action = $action;
         $log->model = $this->className();
         $log->message = $message;
         $log->object = $this;
         if ($save) {
             return $log->save();
         } else {
             return $log;
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Log a custom message
  * 
  * @param string $action eg update, save
  * @param string $message 
  */
 public static function create($action, $message, $model_name = "", $model_id = 0)
 {
     $log = new Log();
     $log->model_id = $model_id;
     $log->action = $action;
     $log->model = $model_name;
     $log->message = $message;
     $log->save();
 }