示例#1
0
 public function log(AuditLog $event = null)
 {
     if (empty($event)) {
         return;
     }
     $array = array('typeId' => $event->getType(), 'type' => $event->getTypeId(), 'description' => $event->getDescription(), 'user' => $event->getUser(), 'impersonatingUser' => $event->getImpersonatingUser(), 'ip' => $event->getIp());
     $fs = new Filesystem();
     $fs->mkdir($this->dir);
     file_put_contents($this->dir . DIRECTORY_SEPARATOR . "audit.log", serialize($array));
 }
 /**
  * @param BaseAuditLog $entity
  * @throws \Exception
  */
 protected function setUser(BaseAuditLog $entity)
 {
     $userProperty = $this->container->getParameter('xiidea.easy_audit.user_property');
     if (null === ($user = $this->getUser())) {
         $entity->setUser($this->getAnonymousUserName());
         return;
     }
     $entity->setUser($this->getSettablePropertyValue($userProperty, $user));
 }
示例#3
0
 /**
  * @param BaseAuditLog $eventInfo
  * @param $logger
  * @param $id
  * @return bool
  */
 protected function isValidLoggerForThisEvent(BaseAuditLog $eventInfo, $logger, $id)
 {
     return $logger instanceof LoggerInterface && $this->isChannelRegisterWithLogger($id, $eventInfo->getLevel());
 }
 /**
  * @param BaseAuditLog $entity
  * @param $userProperty
  */
 protected function setImpersonatingUser(BaseAuditLog $entity, $userProperty)
 {
     if (null !== ($user = $this->getImpersonatingUser())) {
         $entity->setImpersonatingUser($this->getSettablePropertyValue($userProperty, $user));
     }
 }